Best place to start contributions
I'm thinking of helping out with this project. Where is a good place to start?
Off-the-cuff, I can see starting to add Postgresql support to the library, but I'm happy to start somewhere less ambitious.
PostgreSQL support would be OK.
Some other things to do:
-
Add convenient unpacking support.
# Something like this for a, b in db.rows[:(int64, string)](sql"SELECT 1, 'foo'"): ... # Instead of this for row in db.rows(sql"SELECT 1, 'foo'"): let a = row[0].i let b = row[1].s ... # or this for row in db.instantRows(sql"SELECT 1, 'foo'"): let a = row[0, int64] let b = row[1, string] ... -
Prepared statements support.
-
Decouple common procs from SQLite-specific procs. This is partly done: procs marked with
# Specificare specific to SQLite, whereas procs marked with# Commoncould be reused by other DMBS wrappers. Perhaps it may be easier to do after adding other wrappers, to make sure that these common procs actutally can be reused.
@xzfc ,
I'm also helping out with the norm project, which is an ORM using Nim's native objects with databases. For that project, adding PostgreSQL is key. So, I'm thinking of this:
-
write a short "How to use ndb" document to complement the technical documentation. I enjoy writing and having such a general document could be useful. And, more importantly, you can check my understanding of the library to make sure it matches up with your vision.
-
Write a first pass at adding PostgreSQL support with a eye towards what parts are specific to sqlite and what parts are general between both databases. On this first pass, I will probably not support array and map columns, but I'll keep them in mind. I'll generate a "[WIP]" PR so that you can see progress and make comments as it goes along. I'll be mostly working on the weekends for this.
Sound good to you?
cc: @moigagoo
Sounds good. Also I'll publish an wiki page about project design choices soon.
Here: https://github.com/xzfc/ndb.nim/wiki/RFC
There is not a way to add commentary to a wiki, not that I can see anyway. So, I'll add my thoughts here.
https://github.com/xzfc/ndb.nim/wiki/RFC#generalize-dbvalue
I've been thinking about this for a bit. I strongly recommend (b) db_* modules should reuse the common DbValue.
A few reasons for this:
-
Any app that uses multiple databases will find it very convenient. It's not just about avoiding conflicting namespaces, but also about having a good way to allow conversion. For example, if I have a row I'm importing from postgresql, and I want to save that row on sqlite, and one of the columns is a
bool, it would be very nice that sqlite knew what do with a bool. (Which is to convert it to a INT.) And, yes, there are a lot of weird ones that would convert to TEXT/VARCHAR columns in other databases, but I don't see that as a burden, but a benefit that simply needs good documentation. -
I'd keep it in a separate sub-library "x", so that projects that don't even use databases can find it of value. For example, if someone wanted to write a new database library. Essentially, both
ndb/sqliteandndb/postgreswould importndb/x. Speaking of... -
To prep for this possibly becoming part of the standard library, I recommend getting a copy of
db_commonand making DbValue part ofdb_common. For now,sqliteandpostgresqlwould importndb/db_common. But later, they would simply importdb_commonif/when it becomes part of the standard library.