You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an unconventional request - I would like to connect to an SQLite database and perform queries on it, via Postgres.js, eg:
importpostgresfrom'postgres'// Connect to SQLite databaseconstsql=postgres({database: './database.db'})// Query SQLite databaseconstusers=sql`SELECT * FROM users`;
This is to take advantage of all DX / tooling benefits of Postgres.js.
I realize that this may not be the goal of the Postgres.js library, nor does the name Postgres.js describe the usage above (maybe SQL.js for a combined library or SQLite.js would be alternative names for this).
Workaround 1
Use sqld to enable PostgreSQL wire protocol to a SQLite database:
@JAForbes will do! I'll keep the Workaround 1 demo section above updated, as they fix the bugs I encounter. I think it's probably pretty close to working already (you can check out the repo + workflows at the links above if you're interested)
I mentioned it in my description a bit above, but to reiterate: the DX is unparalleled and it would be great to have this also with other database engines. Trying to avoid a good idea being held back by the library name. Some ideas (also posted in my description above): a new adapter library could be created, a new generic library name could be created, a core could be extracted, etc.
@karlhorky definitely not a bad request / idea - i love it!! I've been very close to reaching for sqlite in various scenarios, but simply didn't because I couldn't use it like I use PostgreSQL with Postgres.js...
Unfortunately my time is very limited, so I don't know how much I can participate in exploring it, but I'll follow the conversation eagerly ;)
I think they are two different animals, whenever they try to encompass more target techs, to get something like a Swiss Knife, stuff get's complicated, hard to understand and hard to use, wish is the main reason I think we use this lib to do PostgreSQL, simplicity , easy of use, really fast and really close to the metal.
I think would be wiser to fork this one and adapt it to SQLite, with that exact use case in mind, not something aiming to harness two wild beasts.
I mean if libsql implements the wire protocol then there should be no extra work to do, I've been watching the repo and they are making great headway, I think all the work required is just to raise issues as they arise and let them look into it.
Also, the postgres wire protocol is becoming a pseudo standard that lots of database engines are adhering to, so I doubt this is the first or the last time this sort of request will come up, whether it's for materialize, or yugabyte, or libsql etc.
Repository owner locked and limited conversation to collaborators on Jun 26, 2023
Activity
JAForbes commentedon Mar 16, 2023
Please let us know how you go with
sqld, I'm also very interested in this. @karlhorkykarlhorky commentedon Mar 16, 2023
@JAForbes will do! I'll keep the Workaround 1 demo section above updated, as they fix the bugs I encounter. I think it's probably pretty close to working already (you can check out the repo + workflows at the links above if you're interested)
mattbishop commentedon Mar 16, 2023
This library is called
postgres, why do you thing it should "support" sqlite?karlhorky commentedon Mar 16, 2023
I mentioned it in my description a bit above, but to reiterate: the DX is unparalleled and it would be great to have this also with other database engines. Trying to avoid a good idea being held back by the library name. Some ideas (also posted in my description above): a new adapter library could be created, a new generic library name could be created, a core could be extracted, etc.
porsager commentedon Mar 16, 2023
@karlhorky definitely not a bad request / idea - i love it!! I've been very close to reaching for sqlite in various scenarios, but simply didn't because I couldn't use it like I use PostgreSQL with Postgres.js...
Unfortunately my time is very limited, so I don't know how much I can participate in exploring it, but I'll follow the conversation eagerly ;)
daguitosama commentedon Jun 11, 2023
I think they are two different animals, whenever they try to encompass more target techs, to get something like a Swiss Knife, stuff get's complicated, hard to understand and hard to use, wish is the main reason I think we use this lib to do PostgreSQL, simplicity , easy of use, really fast and really close to the metal.
I think would be wiser to fork this one and adapt it to SQLite, with that exact use case in mind, not something aiming to harness two wild beasts.
JAForbes commentedon Jun 12, 2023
I mean if libsql implements the wire protocol then there should be no extra work to do, I've been watching the repo and they are making great headway, I think all the work required is just to raise issues as they arise and let them look into it.
Also, the postgres wire protocol is becoming a pseudo standard that lots of database engines are adhering to, so I doubt this is the first or the last time this sort of request will come up, whether it's for materialize, or yugabyte, or libsql etc.