Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: no such table: fsdir #116

Open
7flash opened this issue Jan 5, 2024 · 3 comments
Open

Error: no such table: fsdir #116

7flash opened this issue Jan 5, 2024 · 3 comments

Comments

@7flash
Copy link

7flash commented Jan 5, 2024

Jan05-2039.ts

import { Database } from "https://deno.land/x/sqlite3/mod.ts";

const db = new Database(":memory:");

const sqlQuery = Deno.args[0];

const stmt = db.prepare(sqlQuery);
const result = stmt.all();

for (const row of result) {
  console.log(row);
}

Execute sql

deno run --unstable -A ./Jan05-2039.ts "
select
  name as file,
  lines.rowid as line_number,
  line
from fsdir('.')
join lines_read(name) as lines
where name like '%.txt';
"

Gives an error

error: Uncaught (in promise) Error: no such table: fsdir
    throw new Error(Deno.UnsafePointerView.getCString(sqlite3_errmsg(db)!));
          ^
@DjDeveloperr
Copy link
Member

I don't think this vtable is available by default in SQLite3. You will have to load up an extension.
Ref: https://sqlite.org/src/doc/tip/ext/misc/fileio.c

@7flash
Copy link
Author

7flash commented Jan 9, 2024

I don't think this vtable is available by default in SQLite3. You will have to load up an extension. Ref: https://sqlite.org/src/doc/tip/ext/misc/fileio.c

Usually I'm loading extensions like this

import * as sqlite_vss from "https://deno.land/x/sqlite_vss/mod.ts";

const db = new Database("headlines.db");

db.enableLoadExtension = true;

db.loadExtension('./lines0');

Given lines0.dylib downloaded from https://github.com/asg017/sqlite-lines/releases to the same folder


Where can I find fileio.dylib ?

@DjDeveloperr
Copy link
Member

I believe you have to compile it yourself, unless there are prebuilt binaries available elsewhere. fileio ext is in the sqlite source itself, and it's a single C file that you can compile to a dylib: https://sqlite.org/src/file/ext/misc/fileio.c - can check the sqlite docs for more instructions on how to compile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants