-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7f445dc
commit 1b9e8a9
Showing
1 changed file
with
22 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,29 @@ | ||
import gleam/dynamic | ||
import gleam/int | ||
import gleam/io | ||
import gleam/list | ||
import gleam/string | ||
import gleam/set.{type Set} | ||
import sqlight | ||
|
||
pub fn main() { | ||
io.println("Hello from sqlite_merger!") | ||
|
||
use conn <- sqlight.with_connection("file:bookmarks.db") | ||
let query = "SELECT id, url FROM bookmarks;" | ||
let decoder = dynamic.tuple2(dynamic.int, dynamic.string) | ||
let message = case | ||
fn list_items(db: String) -> Set(Int) { | ||
use conn <- sqlight.with_connection("file:" <> db) | ||
let query = "SELECT id, id FROM bookmarks;" | ||
let decoder = dynamic.element(0, dynamic.int) | ||
let assert Ok(ids) = | ||
sqlight.query(query, on: conn, with: [], expecting: decoder) | ||
{ | ||
Error(e) -> e.message | ||
Ok(res) -> | ||
res | ||
|> list.map(fn(x) { x.0 }) | ||
|> list.map(fn(x) { int.to_string(x) }) | ||
|> list.map(fn(x) { x <> " " }) | ||
|> string.concat | ||
} | ||
io.println(message) | ||
|
||
ids | ||
|> list.map(fn(x) { x }) | ||
|> set.from_list | ||
} | ||
|
||
fn diff_items(db1: String, db2: String) -> Set(Int) { | ||
let items1 = list_items(db1) | ||
let items2 = list_items(db2) | ||
|
||
set.difference(items1, items2) | ||
} | ||
|
||
pub fn main() { | ||
let ids = list_items("bookmarks.db") | ||
io.println("Hey") | ||
} |