Skip to content

BUG: SQL get_schema generates incorrect DDL for specific dialect #8697

Closed
@hammer

Description

@hammer

I'm importing data from an Excel spreadsheet and I'd like to generate a CREATE TABLE statement for PostgreSQL that matches the data I've imported from Excel.

Here's what I've got so far:

>>> import pandas as pd
>>> from sqlalchemy import create_engine
>>> import psycopg2
>>> basedata = pd.read_excel('mydata.xlsx')
>>> engine = create_engine('postgresql://myusername@localhost:5432/mydb')
>>> pd.io.sql.get_schema(basedata, 'basedata', con=engine)

Unfortunately the CREATE TABLE statement generated uses a column type of "DATETIME" that does not exist in PostgreSQL. I suspect that the engine object is being ignored somehow and the DDL I'm getting is for sqlite, not PostgreSQL. However, I can't get pandas to build on my Mac so that I can expand the tests to validate my assumption.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIO SQLto_sql, read_sql, read_sql_query

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions