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

Do you have plan to support sqlite3? #88

Open
jacobzeng opened this issue Feb 17, 2023 · 11 comments
Open

Do you have plan to support sqlite3? #88

jacobzeng opened this issue Feb 17, 2023 · 11 comments

Comments

@jacobzeng
Copy link

Thank you first for the repo.
Do you have plan to support sqlite3?

@glebarez
Copy link
Owner

it is indeed sqlite3. What do you mean?

@misterunix
Copy link

@jacobzeng you can use this repo just like you would use "github.com/mattn/go-sqlite3". I have had very good results using this repo.

@jacobzeng
Copy link
Author

I can't open DB with sql.Open("sqlite3","data.db") ,maybe I did something wrong?

@jacobzeng
Copy link
Author

@jacobzeng you can use this repo just like you would use "github.com/mattn/go-sqlite3". I have had very good results using this repo.

Thanks for your tip, but I think mattn/go-sqlite3 need CGO, right? I hate that ^^

@glebarez
Copy link
Owner

I can't open DB with sql.Open("sqlite3","data.db") ,maybe I did something wrong?

use

sql.Open("sqlite","data.db")

@misterunix
Copy link

Correct mattn needs cgo, thats why I use this repo.

@benstigsen
Copy link

This issue could probably be closed, but I'm asking in here at the same time.
Why does this module depend on the sqlite3 mattn module?

@glebarez
Copy link
Owner

glebarez commented Jul 5, 2023

This issue could probably be closed, but I'm asking in here at the same time. Why does this module depend on the sqlite3 mattn module?

This repo does not depend on sqlite3 mattn module (see go.mod).
But underlying sqlite lib has it in its go.mod (but still does not use it in code, only for tests)
see https://gitlab.com/cznic/sqlite/-/issues/69

@benstigsen
Copy link

Ah okay.

@costela
Copy link

costela commented Jul 11, 2023

sql.Open("sqlite","data.db")

The problem with that suggestion is that there are loads of code out there (e.g. ent) that check against the well-known "sqlite3" string to choose SQL dialects.

I see at least a couple of alternatives to deal with this and keep backward-compatibility:

  • add a "compat" subpackage that just does sql.Register("sqlite3", newDriver()) (has the down-side of "acknowledging" the de-facto standard name of "sqlite3")
  • add a way to get the globally initialized Driver, so that the consumer can re-register it under a different name (more flexible but less idiomatic)
  • add something like RegisterAs(string) global function to re-register the Driver (also not idiomatic; probably confusing)

@glebarez
Copy link
Owner

sql.Open("sqlite","data.db")

The problem with that suggestion is that there are loads of code out there (e.g. ent) that check against the well-known "sqlite3" string to chose SQL dialects.

I see at least a couple of alternatives to deal with this and keep backward-compatibility:

  • add a "compat" subpackage that just does sql.Register("sqlite3", newDriver()) (has the down-side of "acknowledging" the de-facto standard name of "sqlite3")

  • add a way to get the globally initialized Driver, so that the consumer can re-register it under a different name (more flexible but less idiomatic)

  • add something like RegisterAs(string) global function to re-register the Driver (also not idiomatic; probably confusing)

I really like option 1 of your suggestion, since it will be a simple import of such compat package, without additional calls.
Sounds like good drop-in fix.

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

5 participants