A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/8697 below:

SQL get_schema generates incorrect DDL for specific dialect · Issue #8697 · pandas-dev/pandas · GitHub

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.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4