Pagghiu / SaneCppLibraries

Sane C++ Libraries
https://pagghiu.github.io/SaneCppLibraries
MIT License
507 stars 11 forks source link

Add a database access module. #14

Open sirlordt opened 4 months ago

sirlordt commented 4 months ago

Hello. Is it possible add a database access module abstraction. Similar to JDBC or golang database/sql?

Pagghiu commented 4 months ago

Hi @sirlordt , do you think that it should be a synchronous, asynchronous interface or both?

I have some experience with SQLite and I've already been writing an (async) abstraction for it in the past. What I've been learning is that sometimes a sync interface is more efficient and easier to control.

What drivers do you think would be the most important for a first MVP release?

A database access module abstraction would fit well with the rest of the libraries, but I haven't been thinking about it yet. I am wondering how to reconcile the fact that DB engines use different SQL syntax even for basic things sometimes...

I am not familiar with the golang one and I've been using JDBC too many years ago to remember how they handle these things, I need to refresh my memory 😄

sirlordt commented 4 months ago

Hi, sorry for the delay in replying.

At the beginning you should create sync interfaces would be a very good start. In my opinion taking inspiration from JDBC is the right way. The standard Golang database/sql also does it.

This library should allow to implement drivers that implement low level access to the database. Possibly C++ wrappers on the C libraries that already exist. Strategy Pattern.

Pagghiu commented 4 months ago

Yeah, that sounds reasonable for a start, I will keep this open as an enhancement request. I don't think I will be able to work on it soon because I want first to get the rest of the libraries at least to the 🟩 state 😅.