sqlite3 icon indicating copy to clipboard operation
sqlite3 copied to clipboard

Different API to node-sqlite3

Open JumpLink opened this issue 1 year ago • 5 comments

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.

JumpLink avatar Nov 23 '23 18:11 JumpLink

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.

DjDeveloperr avatar Nov 24 '23 12:11 DjDeveloperr

@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...

JumpLink avatar Nov 24 '23 19:11 JumpLink

@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?

DjDeveloperr avatar Nov 28 '23 05:11 DjDeveloperr

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

JumpLink avatar Nov 28 '23 07:11 JumpLink

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

JumpLink avatar Nov 28 '23 09:11 JumpLink