@yydb/sqlite 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/sqlite3.mjs +4 -1
- package/package.json +5 -5
- package/readme.md +22 -5
- package/src/node.ts +4 -4
package/bin/sqlite3.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
3
|
|
|
4
4
|
import { SqliteDatabase, SqliteSnapshot } from "../src/node.ts";
|
|
5
5
|
|
|
@@ -107,6 +107,9 @@ function main(args) {
|
|
|
107
107
|
if (!command.startsWith(".")) {
|
|
108
108
|
throw new Error("SQL execution is not available; use a dot command");
|
|
109
109
|
}
|
|
110
|
+
if (!existsSync(path)) {
|
|
111
|
+
throw new Error(`database file not found: ${path}`);
|
|
112
|
+
}
|
|
110
113
|
const database = SqliteDatabase.open(path);
|
|
111
114
|
runDotCommand(database, command);
|
|
112
115
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yydb/sqlite",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Bounded read-only SQLite format-3 snapshot reader for YYDB
|
|
3
|
+
"version": "0.1.7",
|
|
4
|
+
"description": "Bounded read-only SQLite format-3 snapshot reader for YYDB - schema inspection, typed record decoding, and blank database creation.",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"sideEffects": false,
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"repository": {
|
|
33
33
|
"type": "git",
|
|
34
34
|
"url": "git+https://github.com/yy-database/yydb.git",
|
|
35
|
-
"directory": "projects/
|
|
35
|
+
"directory": "projects/yydb.ts/emulators/sqlite"
|
|
36
36
|
},
|
|
37
|
-
"homepage": "https://github.com/yy-database/yydb/tree/dev/projects/
|
|
37
|
+
"homepage": "https://github.com/yy-database/yydb/tree/dev/projects/yydb.ts/emulators/sqlite#readme",
|
|
38
38
|
"bugs": {
|
|
39
39
|
"url": "https://github.com/yy-database/yydb/issues"
|
|
40
40
|
},
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@yydb/yydb": "0.1.
|
|
51
|
+
"@yydb/yydb": "0.1.7"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/node": "^22.15.0",
|
package/readme.md
CHANGED
|
@@ -4,14 +4,31 @@ Read-only inspection of SQLite format-3 main files. Copies bytes into memory, li
|
|
|
4
4
|
|
|
5
5
|
SQLite files are not YYDS storage. They are not routed through `.yyds` catalogs or `.yykv` shards.
|
|
6
6
|
|
|
7
|
+
## Scope
|
|
8
|
+
|
|
9
|
+
Supported:
|
|
10
|
+
|
|
11
|
+
- Format-3 main files with page sizes from 512 to 65536 bytes, including UTF-8, UTF-16le, and UTF-16be text.
|
|
12
|
+
- `sqlite_master` / `sqlite_schema` reads with `CREATE` source preserved as opaque text.
|
|
13
|
+
- Rowid-table B-tree scans, including interior pages, implicit rowids, `INTEGER PRIMARY KEY` aliases, composite-key rowid tables, and overflow payloads.
|
|
14
|
+
- Storage-class record decoding (`NULL`, integer, real, text, blob) through `tableDecoded` and `decodeRecord`.
|
|
15
|
+
|
|
16
|
+
Not supported:
|
|
17
|
+
|
|
18
|
+
- SQL execution of any kind, including `SELECT`, views, triggers, and virtual tables.
|
|
19
|
+
- Writes, transactional paging, journals, WAL recovery, and live-database consistency. A snapshot is the copied main-file bytes at the moment of reading.
|
|
20
|
+
- Encrypted or non-format-3 files, and index B-tree scans such as `WITHOUT ROWID` tables.
|
|
21
|
+
|
|
22
|
+
Values are on-disk storage classes, not SQL-projected results. `NULL` and the empty string stay distinct, an `INTEGER PRIMARY KEY` alias column is returned as `NULL` rather than substituted with the rowid, and REAL affinity is not applied, so an integral REAL input can decode as an integer. Use the schema `sql` source to map aliases and declared types.
|
|
23
|
+
|
|
7
24
|
## Exports
|
|
8
25
|
|
|
9
26
|
| Subpath | Use |
|
|
10
27
|
|---------|-----|
|
|
11
|
-
| `@yydb/sqlite` | Types
|
|
12
|
-
| `@yydb/sqlite/node` |
|
|
28
|
+
| `@yydb/sqlite` | Types plus `SqliteSnapshot`, `SqliteDatabase`, and `decodeRecord` |
|
|
29
|
+
| `@yydb/sqlite/node` | The same reader surface (requires the `@yydb/yydb` platform addon at call time) |
|
|
13
30
|
|
|
14
|
-
The `sqlite3` command supports `.tables
|
|
31
|
+
The `sqlite3` command supports `.tables`, `.schema`, `.dump`, `.ping`, `.encoding`, and `.version` on a file path. It does not run SQL statements.
|
|
15
32
|
|
|
16
33
|
## Example
|
|
17
34
|
|
|
@@ -24,8 +41,8 @@ const tables = snapshot.schema().filter((o) => o.kind === "table");
|
|
|
24
41
|
const rows = snapshot.table("samples", { maxRows: 100 });
|
|
25
42
|
```
|
|
26
43
|
|
|
27
|
-
Each row is `{ rowid: bigint, payload: Buffer }`
|
|
44
|
+
Each row is `{ rowid: bigint, payload: Buffer }` �?storage bytes, not SQL-projected values. Schema `sql` fields are opaque CREATE text. The default snapshot size cap is 256 MiB; each scan accepts `maxPages`, `maxRows`, `maxPayloadBytes`, and `maxTotalPayloadBytes`.
|
|
28
45
|
|
|
29
46
|
## Related packages
|
|
30
47
|
|
|
31
|
-
- [`@yydb/
|
|
48
|
+
- [`@yydb/yydb`](https://github.com/yy-database/yydb/tree/dev/projects/yydb.ts/packages/yydb) �?hosts the native `SqliteSnapshot` binding through its platform addon
|
package/src/node.ts
CHANGED
|
@@ -22,20 +22,20 @@ export interface SqliteSchemaObject {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export interface SqliteTableRow {
|
|
25
|
-
rowid:
|
|
25
|
+
rowid: bigint;
|
|
26
26
|
payload: Buffer;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export interface SqliteRecordValue {
|
|
30
30
|
kind: string;
|
|
31
|
-
valueInteger?:
|
|
31
|
+
valueInteger?: bigint | null;
|
|
32
32
|
valueReal?: number | null;
|
|
33
33
|
valueText?: string | null;
|
|
34
34
|
valueBlob?: Buffer | null;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export interface SqliteDecodedRow {
|
|
38
|
-
rowid:
|
|
38
|
+
rowid: bigint;
|
|
39
39
|
columns: SqliteRecordValue[];
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -65,7 +65,7 @@ export interface SqliteDatabaseBinding {
|
|
|
65
65
|
export type SqliteTextEncoding = "utf8" | "utf16le" | "utf16be";
|
|
66
66
|
|
|
67
67
|
function loadSqliteNative() {
|
|
68
|
-
const native = loadNative() as Record<string, unknown>;
|
|
68
|
+
const native = loadNative() as unknown as Record<string, unknown>;
|
|
69
69
|
if (typeof native.SqliteSnapshot !== "function") {
|
|
70
70
|
throw new Error("Native addon lacks the SQLite snapshot reader. Rebuild the native package.");
|
|
71
71
|
}
|