ENH: Have DataFrame.to_sql()
return the created Table
object
#42645
Labels
Enhancement
IO SQL
to_sql, read_sql, read_sql_query
Needs Discussion
Requires discussion from core team before further action
Is your feature request related to a problem?
I would like to be able to query a table immediately after creating it using
df.to_sql()
, in the SQLAlchemy interface.Describe the solution you'd like
Currently
to_sql()
has no return value. I suggest simply returning the new table object, which is of typesqlalchemy.Table
.API breaking implications
None, as
to_sql()
currently has no return value.Describe alternatives you've considered
Table
object from theautomap
extension. However this is redundant as Pandas at some point generated the table metadata so this would involve throwing it away and then trying to guess what it used to be from the state of the database.Additional context
This conflicts with #23998, which suggests that we return the
ResultProxy
instead. Perhaps we return both, as a tuple? Both of these objects would be useful.The text was updated successfully, but these errors were encountered: