TypeError: db.execute is not a function
import { drizzle } from 'drizzle-orm/better-sqlite3';
import Database from 'better-sqlite3';
const sqlite = new Database('sqlite.db');
const db = drizzle({ client: sqlite });
const result = await db.execute('select 1');
has anyone been able to run the last command without the above error. The example is taken from the documentation, last example https://orm.drizzle.team/docs/get-started-sqlite#better-sqlite3
Drizzle ORM - SQLite
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
6 Replies
The docs are wrong there, for SQLite you have run, get, values and all
thank very much
Quick question Angel, is sql.run safe to use (from injections and everything) without the sql`` operator?
I'm going to use a query for my FTS5 table and yeah, there are no queries for that, and I don't want to use the operator because I don't have the virtual table in the Schema.
You can use the sql operator even if the tables your are working with are not in the schema. I believe that for table name and column names you can use sql.name()
Inside the sql operator
If you send an example query I can show you how to do it
Thanks for answering! I don't really have any examples now, I was just wondering if run was safe, if it did the required sanitations and so forth, but as you're mentioning I guess I can just use the operator to be safe.
Yes, anything that’s user input you pass it to the sql operator and it will prevent injection attacks