Hello,
This enhancement is quite similar to https://github.com/pydata/pandas/issues/10654
to_sql
method should accept database URI as con parameter
So we could do
import pandas as pd
db_uri = 'dialect+driver://username:password@host:port/database'
query = 'SELECT * FROM table'
df.to_sql("table", db_uri)
instead of :
import pandas as pd
from sqlalchemy import create_engine
db_uri = 'dialect+driver://username:password@host:port/database'
engine = create_engine(db_uri)
df.to_sql("table", engine)
Might apply to : - Series http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.to_sql.html - Panel http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Panel.to_sql.html - and DataFrame http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.to_sql.html
Blaze uses table URI like 'dialect+driver://username:password@host:port/database::table'
so passing table as parameter is not necessary, as it is contained inside (table) URI
but It may be difficult to mimic this API without breaking eggs (con
should be first parameter and table
should be second with a default None
value)
Kind regards
Comment From: jorisvandenbossche
This can be done together with doing this for read_sql
, so closing this in favor of #10654