Open
Description
pd.io.sql.get_schema
can be used to see the schema 'create table' statement. This function should support including the index (which is actually the default for to_sql
)
In [31]: df = pd.DataFrame({'col':[1,2,3]}, index=pd.date_range('2012-01-01', periods=3))
In [33]: print pd.io.sql.get_schema(df, 'test_schema', con=engine_postgres)
CREATE TABLE test_schema (
col BIGINT
)
In [34]: print pd.io.sql.get_schema(df.reset_index(), 'test_schema', con=engine_postgres)
CREATE TABLE test_schema (
index TIMESTAMP WITHOUT TIME ZONE,
col BIGINT
)