-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: support index=True for SQL io.sql.get_schema #9084
Labels
Comments
jorisvandenbossche
added
IO SQL
to_sql, read_sql, read_sql_query
Enhancement
Good as first PR
labels
Dec 15, 2014
I can create a PR for this if wanted. Would we want the patch (i assume so) to be backwards compatible with |
vrajmohan
pushed a commit
to vrajmohan/pandas
that referenced
this issue
Jan 30, 2019
Closes pandas-dev#9084 - Decided to keep the default as index=False to keep the API consistent. `to_sql` has index=True. - Tempted to name the parameter `include_dataframe_index` as "index" has a different meaning in a SQL context.
vrajmohan
pushed a commit
to vrajmohan/pandas
that referenced
this issue
Jan 30, 2019
Closes pandas-dev#9084 - Decided to keep the default as `index=False` to keep the API consistent. `to_sql` has `index=True`. - Tempted to name the parameter `include_dataframe_index` as "index" has a different meaning in a SQL context.
2 tasks
vrajmohan
pushed a commit
to vrajmohan/pandas
that referenced
this issue
Feb 1, 2019
Closes pandas-dev#9084 - Decided to keep the default as `index=False` to keep the API consistent. `to_sql` has `index=True`. - Tempted to name the parameter `include_dataframe_index` as "index" has a different meaning in a SQL context.
After adding the index option, the returned default "index" name has double quotes. Is this expected? df = pd.DataFrame({
"one": [1, 2, 3], "two": [1, 2, 3]
}, index=list("abc"))
schema_with_index = sql.get_schema(df, 'test', index=True, con=self.conn)
CREATE TABLE test (
"index" TEXT,
one BIGINT,
two BIGINT
)
df.index.name = 'new_index'
schema_with_index_rename = sql.get_schema(df, 'test', index=True, con=self.conn)
CREATE TABLE test (
new_index TEXT,
one BIGINT,
two BIGINT
) |
5 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 forto_sql
)The text was updated successfully, but these errors were encountered: