diff --git a/.envrc b/.envrc deleted file mode 100644 index d324c24..0000000 --- a/.envrc +++ /dev/null @@ -1,2 +0,0 @@ -source_env .. -use nix diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 8454dc7..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/nim.cfg diff --git a/README.md b/README.md index d694ae6..8836309 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,5 @@ # sqlite_actor -Syndicate actor for accessing SQLite databases. +Absorbed by the Syndesizer -## Build - -Depends on the [SQLcipher](https://www.zetetic.net/sqlcipher/) library and pkg-config. - -## Example configuration -``` -? [ - - $ds - - $ds ? [ - $log ! }> - ] - - > - ? ?cap> [ - $cap { - dataspace: $ds - database: "/var/db/example.db" - } - ] - - -] -``` +https://git.syndicate-lang.org/ehmry/syndicate_utils diff --git a/Tupfile b/Tupfile deleted file mode 100644 index 28c450e..0000000 --- a/Tupfile +++ /dev/null @@ -1,2 +0,0 @@ -include_rules -: lock.json |> !nim_cfg |> | ./ diff --git a/Tuprules.tup b/Tuprules.tup deleted file mode 100644 index 189eba9..0000000 --- a/Tuprules.tup +++ /dev/null @@ -1,3 +0,0 @@ -include ../syndicate-nim/depends.tup -NIM_FLAGS += --path:$(TUP_CWD)/../syndicate-nim/src -NIM_GROUPS += $(TUP_CWD)/ diff --git a/lock.json b/lock.json deleted file mode 100644 index 6e7cd50..0000000 --- a/lock.json +++ /dev/null @@ -1 +0,0 @@ -{"depends":[{"method":"fetchzip","packages":["hashlib"],"path":"/nix/store/v03nzlpdgbfxd2zhcnkfbkq01d5kqxcl-source","rev":"84e0247555e4488594975900401baaf5bbbfb53","sha256":"1pfczsv8kl36qpv543f93d2y2vgz2acckssfap7l51s2x62m6qwx","srcDir":"","url":"https://github.com/khchen/hashlib/archive/84e0247555e4488594975900401baaf5bbbfb53.tar.gz"},{"method":"fetchzip","packages":["nimcrypto"],"path":"/nix/store/zyr8zwh7vaiycn1s4r8cxwc71f2k5l0h-source","ref":"traditional-api","rev":"602c5d20c69c76137201b5d41f788f72afb95aa8","sha256":"1dmdmgb6b9m5f8dyxk781nnd61dsk3hdxqks7idk9ncnpj9fng65","srcDir":"","url":"https://github.com/cheatfate/nimcrypto/archive/602c5d20c69c76137201b5d41f788f72afb95aa8.tar.gz"},{"method":"fetchzip","packages":["npeg"],"path":"/nix/store/ffkxmjmigfs7zhhiiqm0iw2c34smyciy-source","ref":"1.2.1","rev":"26d62fdc40feb84c6533956dc11d5ee9ea9b6c09","sha256":"0xpzifjkfp49w76qmaylan8q181bs45anmp46l4bwr3lkrr7bpwh","srcDir":"src","url":"https://github.com/zevv/npeg/archive/26d62fdc40feb84c6533956dc11d5ee9ea9b6c09.tar.gz"},{"method":"fetchzip","packages":["preserves"],"path":"/nix/store/nrcpzf9hx70kry3gwhrdzcs3qicjncjh-source","ref":"20231021","rev":"edece399be70818208bf2263c30cb2bcf435bbff","sha256":"0xmw35wmw3a4lja9q4qvlvpxv3xk0hnkjg4fwfw6f3inh6zfiqki","srcDir":"src","url":"https://git.syndicate-lang.org/ehmry/preserves-nim/archive/edece399be70818208bf2263c30cb2bcf435bbff.tar.gz"},{"method":"fetchzip","packages":["syndicate"],"path":"/nix/store/1y3nnpp2mhxqmdb3xh4c4k5k5l9hhqk3-source","ref":"20231019","rev":"57b99b20e7db1b97b1cb9c6df574bd13983c26fc","sha256":"1kgb3a78igs37xkmv8cbaxa17qdjf2h43vdmpda517c9086ggsn5","srcDir":"src","url":"https://git.syndicate-lang.org/ehmry/syndicate-nim/archive/57b99b20e7db1b97b1cb9c6df574bd13983c26fc.tar.gz"}]} diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 9e0a572..0000000 --- a/shell.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ pkgs ? import { } }: - -pkgs.nim2Packages.buildNimPackage { - name = "dummy"; - propagatedNativeBuildInputs = [ pkgs.pkg-config ]; - propagatedBuildInputs = [ pkgs.sqlcipher ]; -} diff --git a/sql.prs b/sql.prs deleted file mode 100644 index 679a7e6..0000000 --- a/sql.prs +++ /dev/null @@ -1,6 +0,0 @@ -version 1 . - -; When asserted the actor reponds with -; rows as records of the given label and -; row columns as record fields. -Query = . diff --git a/sqlite_actor.nimble b/sqlite_actor.nimble deleted file mode 100644 index d2b364c..0000000 --- a/sqlite_actor.nimble +++ /dev/null @@ -1,8 +0,0 @@ -version = "20231021" -author = "Emery Hemingway" -description = "Syndicate Actor for accessing SQLite databases" -license = "Unlicense" -srcDir = "src" -bin = @["sqlite_actor"] - -requires "nim >= 1.6.10", "syndicate >= 20230518" diff --git a/src/Tupfile b/src/Tupfile deleted file mode 100644 index 2ee2cbb..0000000 --- a/src/Tupfile +++ /dev/null @@ -1,4 +0,0 @@ -include_rules -: foreach ../*.prs |> !preserves_schema_nim |> {schema} -: sqlite_actor.nim | $(SYNDICATE_PROTOCOL) {schema} |> !nim_bin |> {bin} -: {bin} |> !assert_built |> diff --git a/src/sql.nim b/src/sql.nim deleted file mode 100644 index 4702c16..0000000 --- a/src/sql.nim +++ /dev/null @@ -1,14 +0,0 @@ - -import - preserves - -type - Query* {.preservesRecord: "query".} = object - `label`*: Preserve[void] - `statement`*: string - -proc `$`*(x: Query): string = - `$`(toPreserve(x)) - -proc encode*(x: Query): seq[byte] = - encode(toPreserve(x)) diff --git a/src/sqlite_actor.nim b/src/sqlite_actor.nim deleted file mode 100644 index 728f8d7..0000000 --- a/src/sqlite_actor.nim +++ /dev/null @@ -1,112 +0,0 @@ -# SPDX-FileCopyrightText: ☭ Emery Hemingway -# SPDX-License-Identifier: Unlicense - -# Avoid Sqlite3 from the standard library because it is -# only held together by wishful thinking and dlload. - -{.passC: staticExec("pkg-config --cflags sqlcipher").} -{.passL: staticExec("pkg-config --libs sqlcipher").} - -{.pragma: sqlite3h, header: "sqlite3.h".} - -var - SQLITE_VERSION_NUMBER {.importc, sqlite3h.}: cint - SQLITE_OK {.importc, sqlite3h.}: cint - SQLITE_ROW {.importc, sqlite3h.}: cint - SQLITE_DONE {.importc, sqlite3h.}: cint - SQLITE_OPEN_READONLY {.importc, sqlite3h.}: cint - -const - SQLITE_INTEGER = 1 - SQLITE_FLOAT = 2 - SQLITE_TEXT = 3 - SQLITE_BLOB = 4 - # SQLITE_NULL = 5 - -type - Sqlite3 {.importc: "sqlite3", sqlite3h.} = distinct pointer - Stmt {.importc: "sqlite3_stmt", sqlite3h.} = distinct pointer - -{.pragma: importSqlite3, importc: "sqlite3_$1", sqlite3h.} - -proc libversion_number: cint {.importSqlite3.} - -proc open_v2(filename: cstring; ppDb: ptr Sqlite3; flags: cint; zVfs: cstring): cint {.importSqlite3.} -proc close(ds: Sqlite3): int32 {.discardable, importSqlite3.} - -proc errmsg(db: Sqlite3): cstring {.importSqlite3.} - -proc prepare_v2(db: Sqlite3; zSql: cstring, nByte: cint; ppStmt: ptr Stmt; pzTail: ptr cstring): cint {.importSqlite3.} - -proc step(para1: Stmt): cint {.importSqlite3.} - -proc column_count(stmt: Stmt): int32 {.importSqlite3.} -proc column_blob(stmt: Stmt; col: cint): pointer {.importSqlite3.} -proc column_bytes(stmt: Stmt; col: cint): cint {.importSqlite3.} -proc column_double(stmt: Stmt; col: cint): float64 {.importSqlite3.} -proc column_int64(stmt: Stmt; col: cint): int64 {.importSqlite3.} -proc column_text(stmt: Stmt; col: cint): cstring {.importSqlite3.} -proc column_type(stmt: Stmt; col: cint): cint {.importSqlite3.} -proc finalize(stmt: Stmt): cint {.importSqlite3.} - -doAssert libversion_number() == SQLITE_VERSION_NUMBER - -import preserves, syndicate, syndicate/relays -import ./sql - -proc logError(db: Sqlite3; context: string) = - writeLine(stderr, errmsg(db), ": ", context) - -type - Value = Preserve[void] - Args {.preservesDictionary.} = object - database: string - dataspace: Cap - -proc extractValue(stmt: Stmt; col: cint): Value = - case column_type(stmt, col) - of SQLITE_INTEGER: - result = toPreserve(column_int64(stmt, col)) - of SQLITE_FLOAT: - result = toPreserve(column_double(stmt, col)) - of SQLITE_TEXT: - result = Value(kind: pkString, string: newString(column_bytes(stmt, col))) - if result.string.len > 0: - copyMem(addr result.string[0], column_text(stmt, col), result.string.len) - of SQLITE_BLOB: - result = Value(kind: pkByteString, bytes: newSeq[byte](column_bytes(stmt, col))) - if result.bytes.len > 0: - copyMem(addr result.bytes[0], column_blob(stmt, col), result.bytes.len) - else: - result = initRecord[void]("null") - -proc extractRecord(stmt: Stmt; label: Value, arity: cint): Value = - result = initRecord(label, arity) - for col in 0..