denodrivers / sqlite3

The fastest and correct SQLite3 module for Deno runtime
https://jsr.io/@db/sqlite
Apache License 2.0
258 stars 21 forks source link

Different API to node-sqlite3 #113

Open JumpLink opened 11 months ago

JumpLink commented 11 months ago

I tried to use this package under Deno with TypeORM which did not work because they differ in API's to node-sqlite3.

Is it an option for you to make the APIs more compatible and would you accept PRs for this?

I also wrote a simple wrapper that makes the API's more compatible. So far I have only tried this with a very simple TypeORM entry, but at least that worked. Maybe this is also useful for someone else.

DjDeveloperr commented 11 months ago

The current API is inspired from Node.js better-sqlite3 module, as a result of rewrite that took place a while ago: #44

It's a pretty simple and synchronous API that allows making best of sqlite3 performance. I see that node-sqlite3 is callback based & non-blocking/asynchronous, which could be a bottleneck.

So I think a separate wrapper is a preferable option, since the current API seems better in terms of simplicity and performance (see https://www.npmjs.com/package/better-sqlite3 for some performance comparison, and this module performs even better than better-sqlite3). Currently, the high performance sqlite3 bindings in Node.js (better-sqlite3), Deno (sqlite3) and Bun (bun:sqlite) ecosystems all have this similar API.

JumpLink commented 11 months ago

@DjDeveloperr Thanks for the answer, that is very good to know that the API is based on better-sqlite3!

There are also drivers in TypeORM for better-sqlite3, so maybe I should just output this package as better-sqlite3, if that would work I could have saved myself the wrapper 😅. Do you think there are still big differences regarding better-sqlite3?

Edit: Okay, I tested it once, there seem to be some differences in the return values, so that would also need adjustments, the question is which is more complex...

DjDeveloperr commented 11 months ago

@JumpLink Using better-sqlite3 driver sounds like a great idea. I can try to help get that to work. There shouldn't be much big differences, which one are you running into here?

JumpLink commented 11 months ago

@DjDeveloperr I can create a simple example for this issue, than other developers like you can test it by himself

JumpLink commented 11 months ago

@DjDeveloperr Here the example: https://github.com/JumpLink/deno-typeorm-sqlite-example with preconfigured settings for debugging Deno and Node.js in VSCode.