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

Support passing existing connections #16

Closed
idomic opened this issue Dec 23, 2022 · 11 comments · Fixed by #22
Closed

Support passing existing connections #16

idomic opened this issue Dec 23, 2022 · 11 comments · Fixed by #22
Assignees

Comments

@idomic
Copy link

idomic commented Dec 23, 2022

The initialization locks the context to a specific engine. See example

We'd like to allow users to connect to an engine directly by reference (similar to SQL alchemy).

@idomic
Copy link
Author

idomic commented Dec 23, 2022

Another great example of this use case (this was solved via the Duckdb team)

@edublancas
Copy link

I'm thinking something like this:

from sqlalchemy import create_engine

engine = create_engine("...")

Then:

%sql $engine

IPython supports variable expansion via $var, but I'm unsure if this will pass the actual object or only its string representation.

@edublancas
Copy link

It's a bit unclear to me the original issue in the ipython-sql repo. I don't understand if the user wants to re-use an existing engine (what I described in the comment above). Or they want to re-use an engine they created with %sql for later queries. Maybe we can ask him and bring the conversation here?

@idomic
Copy link
Author

idomic commented Dec 24, 2022

I think that's the first option.
@machow thoughts?
@Alex-Monahan tagging you since you had the same issue a while ago (it might happen again with new DBs)

@idomic
Copy link
Author

idomic commented Dec 24, 2022

I think this one will also be solved once an engine can be passed dynamically? @zzFluke

@Alex-Monahan
Copy link

This is still a nice and helpful feature, even if DuckDB can already read dataframes without it! One use case is if you store your dataframes in a dict, you would want to be able to register them with DuckDB (since it won't find them djrectly anymore).

@idomic
Copy link
Author

idomic commented Dec 24, 2022

@Alex-Monahan thanks for the feedback! Do you think it's related to this issue or a completely new one?

@Alex-Monahan
Copy link

The ability to either pass in an engine or refer to the engine variable and call a function directly on the connection would work in this case. I think that is what this proposes, but I am not certain!

@idomic
Copy link
Author

idomic commented Dec 24, 2022

Awesome, yes it is!

@edublancas
Copy link

hey @Alex-Monahan, @machow, this has been fixed!

Available in version 0.5.1. Docs here.

Let us know if you have any issues/feedback!

@idomic
Copy link
Author

idomic commented Dec 29, 2022

fyi: @pfmoore @gwerbin @rehno-lindeque @ellisonbg @ckald

Make sure to join our slack for more info and support

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 a pull request may close this issue.

4 participants