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

execute(): support passing parameters as keyword arguments #30

Merged
merged 3 commits into from
Jan 12, 2021

Conversation

alyst
Copy link
Contributor

@alyst alyst commented Jan 8, 2021

This PR complements JuliaDatabases/SQLite.jl#223 by adding keyarg support to DBInterface (for execute(), executemultiple() and executemany()).

I've also added two other minor things:

  • @sql_str macro, so that SQL queries could be written as @sql"....". This should allow embedded SQL highlighting in Julia scripts by IDE plugins as it is done for e.g. @r_str strings of RCall.jl.
  • execute(f, db, sql), which (as open(f, file)) allows applying f to the returned cursor and then closing the query (the query is also closed if f throws).
    This pattern allows tighter control of the prepared statement lifetime, which does not rely on GC to finalize and close the statement object. It also allows DB-specific implementations that don't create prepared statements at all.

@alyst
Copy link
Contributor Author

alyst commented Jan 11, 2021

@quinnj could you please take a look?

Copy link
Member

@quinnj quinnj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great stuff; thanks @alyst!

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

Successfully merging this pull request may close these issues.

2 participants