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

API Trace View

Struggling with slow API calls? 👀

Dan Mindru walks through how he used Sentry's new Trace View feature to shave off 22.3 seconds from an API call.

Get a practical walkthrough of how to identify bottlenecks, split tasks into multiple parallel tasks, identify slow AI model calls, and more.

Read more →

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay