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

Adding new drivers #18

Closed
josejuanmontiel opened this issue Jan 12, 2023 · 5 comments
Closed

Adding new drivers #18

josejuanmontiel opened this issue Jan 12, 2023 · 5 comments

Comments

@josejuanmontiel
Copy link

Hi, i'm playing with sql-jobber ... and asking if could be interesting adding new drivers

https://github.com/sijms/go-ora
_ "github.com/sijms/go-ora/v2" // sql.Open("oracle", "oracle://OT:yourpassword@localhost/XE")

https://github.com/mithrandie/csvq-driver
_ "github.com/mithrandie/csvq-driver" // sql.Open("csvq", "/path/to/data/directory")

And even.. https://pkg.go.dev/cloud.google.com/go/bigquery

I played successfully with the 2 first (i consider use sql-jobber + csvq as option to generate csv files from queries... a prof of concept :) but this leadme to change sqldb.go (backend) in some place to make it csvq dialect compatible with the actual code ... adding new drivers may lead to spread ifs like this

// This will be filled by the driver. if w.backend.opt.DBType == dbTypePostgres { // Postgres placeholders are $1, $2 ... colValHolder[i] = fmt.Sprintf("$%d", i+1) } else { colValHolder[i] = "?" }
or maybe refactor in some way, maybe adding new backend for "non standard sql databases"...

what do you think about it?... if consider interesting i can submit a PR.

@knadh
Copy link
Collaborator

knadh commented Jan 12, 2023

Hi @josejuanmontiel. This is definitely interesting and the more database SQL jobber can support, the more useful it is. Do you have any ideas for an architectural change? I guess there's no way but to hardcode support for multiple DBs into the core. If only Go had a usable plugin system!

@josejuanmontiel
Copy link
Author

Hi... i think we could talk the architectural here because all options incluide change and organice the code in some way to differenciate for specific cases and reuse where it't make sense... i'll try to open a PR in draft in the next days to see this changes in my case (oracle and csvq)... and talk about those...

@josejuanmontiel
Copy link
Author

Hi! Sorry for the delay... the idea could be something like this... #21 still need some refactor... but this could be the idea to reuse the base "sql code" in another kind of tricky sql database.. what do you think?

@knadh
Copy link
Collaborator

knadh commented Jan 29, 2023

Hi @josejuanmontiel. A little confused by the PR. This seems to have a new CSV backend too. Could you describe the PR in some detail?

@josejuanmontiel
Copy link
Author

I commented... hope that understand... but, in resumen i decided implement new CSV backend... better than ifs ... to later import dinamically this code as plugin... and better readability i think :)

@knadh knadh closed this as completed Mar 15, 2024
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