Closed
Description
Currently, there is no way to specify the schema when calling pandas.io.sql.get_schema, the schema is a helpful parameter when working with certain databases such as MSSQL.
import pandas.io.sql
# current state
table_name = 'my_new_table'
sql_create_statement = pandas.io.sql.get_schema(df, table_name, con)
# create statement looks like
"""
CREATE TABLE [my_new_table] (
[column1] VARCHAR(max) NULL,
....
)
"""
this adds an extra step to have to parse the file in order to add the schema, otherwise when I execute the script later, the table is created in user default schema (dbo in most cases). This issue can be easily addressed by adding schema
parameter to _create_sql_schema
since SQLTable
already supports schema
import pandas.io.sql
# future state
table_name = 'my_new_table'
schema = 'pypi'
sql_create_statement = pandas.io.sql.get_schema(df, table_name, schema=schema)
# create statement will look like this for MSSQL if con parameter is passed
"""
CREATE TABLE pypi.[my_new_table] (
[Column1],
....
)
"""