ipython-sql icon indicating copy to clipboard operation
ipython-sql copied to clipboard

allow passing an engine directly to Connection

Open machow opened this issue 3 years ago • 2 comments

Hello--I've really enjoyed using ipython-sql! One challenge I have is that it requires creating a new engine, rather than using an existing one.

I can work around this by having Connection create the engine, and the grabbing it off of that. However, working with all the tools that can take a sqlalchemy engine feels bit easier, if I can make it upfront and then pass it to them.

Thanks for all your work on this tool!

edit: here's the current workaround:

from sql.connection import Connection

con = Connection("duckdb:///:memory:")
con.session.engine

machow avatar Nov 09 '22 21:11 machow

This has been added to JupySQL 0.5.1 (a fork of ipython-sql):

pip install jupysql --upgrade
import pandas as pd
from sqlalchemy.engine import create_engine

engine = create_engine("sqlite://")

df = pd.DataFrame({"x": range(5)})
df.to_sql("numbers", engine)

%load_ext SQL
%sql engine
%%sql
SELECT * FROM numbers

edublancas avatar Dec 28 '22 16:12 edublancas

Ah thanks! I noticed one of the other additions is telemetry from ploomber_core that is opt out. Can you say more about what that's doing?

machow avatar Jan 05 '23 23:01 machow