
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()
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
);
2024-01-16
Related Articles
- SQL Transactions - COMMIT, ROLLBACK, and Savepoints with Python
- How to read and write JSON files in Python
- 10 Essential Data Science Algorithms & Techniques
- How to Use the Concat Function in Pandas for Horizontal or Vertical Table Concatenation
- Oracle Database: How to Create/Delete New User and Grant Privilege?
Add Comments
Comments
Loading comments...