DEV Community

Cover image for Solving Pandas .to_sql Double Quotes Issue When Writing to Database
Luca Liu
Luca Liu

Posted on โ€ข Edited on

Solving Pandas .to_sql Double Quotes Issue When Writing to Database

I have found a solution to the frustrating issue of using pandas to save a dataframe into a database and finding that the column names are encased in double quotes.

By setting the column names to uppercase before writing the dataframe to the database, the double quotes problem can be completely circumvented.



df.columns.str.upper()


Enter fullscreen mode Exit fullscreen mode

When creating the table structure in the database, please ensure that your column names are in uppercase.



CREATE TABLE table_name
(
    COLUMN1     VARCHAR2(50),
    COLUMN2     VARCHAR2(50),
    COLUMN3     Integer
);


Enter fullscreen mode Exit fullscreen mode

Explore more

Thank you for taking the time to explore data-related insights with me. I appreciate your engagement.

๐Ÿš€ Connect with me on LinkedIn

๐ŸŽƒ Connect with me on X

๐ŸŒ Connect with me on Instagram

Image of Timescale

๐Ÿš€ pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applicationsโ€”without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up