Skip to content
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: Added schema kwarg to get_schema method #33278

Closed

Conversation

gregorylivschitz
Copy link

@gregorylivschitz gregorylivschitz commented Apr 3, 2020

@gregorylivschitz gregorylivschitz changed the title Issue 28486 Added schema kwarg to get_schema method. ENH: Added schema kwarg to get_schema method Apr 4, 2020
@alimcmaster1 alimcmaster1 added the IO SQL to_sql, read_sql, read_sql_query label Apr 14, 2020
@alimcmaster1
Copy link
Member

Please can you merge master

pandas/tests/io/test_sql.py Outdated Show resolved Hide resolved
@alimcmaster1
Copy link
Member

Seems like there are some test failures - mind taking a look?

@gregorylivschitz
Copy link
Author

@alimcmaster1

I'm not sure what the issue was, it was not my test that was breaking, I rebased from master again and it seems to be working now.

Copy link
Member

@alimcmaster1 alimcmaster1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there - small comments

doc/source/whatsnew/v1.1.0.rst Outdated Show resolved Hide resolved
pandas/tests/io/test_sql.py Outdated Show resolved Hide resolved
@gregorylivschitz
Copy link
Author

@alimcmaster1
I have completed the requests.

@alimcmaster1
Copy link
Member

This looks good to me @gregorylivschitz mind merging master?

@jreback
Copy link
Contributor

jreback commented Jun 14, 2020

@gregorylivschitz can you merge master

@gregorylivschitz
Copy link
Author

@jreback
It is done.

Copy link
Member

@alimcmaster1 alimcmaster1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - @gregorylivschitz mind merging master?

@MarcoGorelli
Copy link
Member

@gregorylivschitz could you please merge master again? This looks like it's close to being merged

@alimcmaster1
Copy link
Member

@gregorylivschitz whatsnew entry will now be v1.2

Almost there

@gregorylivschitz
Copy link
Author

@alimcmaster1 @MarcoGorelli

I have merged it in. Thanks for reminding me!

@MarcoGorelli MarcoGorelli self-requested a review August 23, 2020 20:12
pandas/io/sql.py Outdated
@@ -1588,9 +1594,13 @@ def _create_table_setup(self):
create_tbl_stmts.append(
f"CONSTRAINT {self.name}_pk PRIMARY KEY ({cnames_br})"
)

if self.schema:
schema_to_add = self.schema + "."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Granted I'm no SQL expert, but perhaps schema_name would be a better variable name?

@@ -866,6 +866,12 @@ def test_get_schema(self):
create_sql = sql.get_schema(self.test_frame1, "test", con=self.conn)
assert "CREATE" in create_sql

def test_get_schema_with_schema(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add the github issue number here, e.g. # GH8624 (but with the correct number)

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gregorylivschitz overall looks good to me, have just left some minor comments

pandas/io/sql.py Outdated
@@ -1455,9 +1455,15 @@ def drop_table(self, table_name, schema=None):
self.get_table(table_name, schema).drop()
self.meta.clear()

def _create_sql_schema(self, frame, table_name, keys=None, dtype=None):
def _create_sql_schema(self, frame, table_name, keys=None, dtype=None, schema=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're here, could you add type annotations to these arguments? Not all old code has them, but they're encouraged for new developments. Feel free to ping if it's not something you're familiar with

@pep8speaks
Copy link

pep8speaks commented Aug 25, 2020

Hello @gregorylivschitz! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2020-08-28 03:32:20 UTC

@github-actions github-actions bot added the Stale label Sep 27, 2020
@WillAyd
Copy link
Member

WillAyd commented Sep 30, 2020

@gregorylivschitz I think this looks good but has a merge conflict and a CI failure - can you take a look? Should be able to get this in soon

Copy link
Member

@arw2019 arw2019 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gregorylivschitz if you merge master and resolve conflicts it sounds like this is good to go in

@arw2019
Copy link
Member

arw2019 commented Nov 29, 2020

Closing in favor of #38146

@arw2019 arw2019 closed this Nov 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO SQL to_sql, read_sql, read_sql_query Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for schema parameter when calling io.sql.get_schema
7 participants