Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sqlite #2

Open
gedw99 opened this issue Jul 3, 2024 · 1 comment
Open

Sqlite #2

gedw99 opened this issue Jul 3, 2024 · 1 comment

Comments

@gedw99
Copy link

gedw99 commented Jul 3, 2024

Hey @RussellLuo

I wonder how tricky it would be to support SQLite with dbtest ?

I use SQLite with Marmot: https://github.com/maxpert/marmot, so that I can run many SQLite instances and keep them in global sync using NATS.

Marmot runs as a separate Process and uses the SQLITE WAL to do its thing.

ddtest would make it easy to test Marmot, and SQLite DB,s in general.

I current use this SQLite DB: https://github.com/ncruces/go-sqlite3


Here is one way for dbTest to supports many databases ...

https://github.com/sqlc-dev/plugin-sdk-go offers a plugin Architecture so that different DB's can be supported with Sqlc. Sqlc is a code generator, not an ORM. It's There are many DBs supported: https://github.com/sqlc-dev/plugin-sdk-go/network/dependents
pretty light.

Some examples

Here is a plunge for the Sqlite DB: https://github.com/zombiezen/go-sqlite.

https://github.com/delaneyj/toolbelt/blob/main/sqlc-gen-zombiezen/zombiezen/gen.go


Here is a plugin for MySQL and SQLite.

https://github.com/crdx/starfield

Anyways lets me know what you think.

@RussellLuo
Copy link
Member

Hi @gedw99, sorry for the delayed response.

By design, any database that implements the following interface can be used in dbtest:

type DB interface {
Insert(data map[string]spec.Rows) error
Delete(keys ...string) error
Select(query string) (spec.Rows, error)
Close() error
}

And for convenience, sql.DB is a built-in support for databases compatible with Go's database/sql.

According to the description of go-sqlite3, it's compatible with Go's database/sql. So I guess you can use the built-in sql.DB directly:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants