Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ENH: Add table prefixes to to_sql method #60422

Open
Labels
Enhancement IO SQLto_sql, read_sql, read_sql_query Needs TriageIssue that has not been reviewed by a pandas team member
@Diadochokinetic

Description

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

Some DBMS support the use of temporary tables. These are tables that only exist within a session and get dropped at the end of a session. These tables are useful for storing intermediary results in longer ETL jobs or for uploading a list of IDs into a otherwise read-only database for further processing. They are created with a CREATE TEMPORARY TABLE statement. At the moment, the to_sql method does not support creating temporary tables or inserting values into a manually created temporary table. At its core, to_sql uses the sqlalchemy.Table class , which supports a parameter prefixes. This parameter inserts a list of keywords before the TABLE keyword and can be used to create temporary tables by setting prefixes=["TEMPORARY"]. I suggest to add a prefixes parameter to to_sql and pass it down to the sqlalchemy.Table.

Feature Description

Add a parameter prefixes to the to_sql method:

df.to_sql(
 name="CUSTOMERS",
 con=engine,
 index=False,
 if_exists="create",
 prefixes=["TEMPORARY"]
)

The parameter needs to work with all possible ways of if_exists, so you can switch between CREATE TEMPORARY TABLE and INSERT functionality.

Alternative Solutions

Thus far, I was not able to find another solution.

Additional Context

I'm already working on a suitable implementation of the feature: #60409

Metadata

Metadata

Assignees

No one assigned

    Labels

    Enhancement IO SQLto_sql, read_sql, read_sql_query Needs TriageIssue that has not been reviewed by a pandas team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /