-
Notifications
You must be signed in to change notification settings - Fork 0
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
Create primary key for new tables #176
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code's overall goals aren't clear immediately to an outsider like me. This is why I have some questions/objections.
schema=schema, | ||
if_exists='replace', | ||
) | ||
# table was just created, create primary key (to_postgis doesn't create these, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're calling to_sql()
above, not to_postgis()
. Can you expand the comment to explain what's going on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment that explains that GeoDataFrame
's methods are not named in a db agnostic as pandas.DataFrame
's to_sql
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Does
con.connection.cursor()
start a new transaction? What if it fails? What if we're already within a transaction? PostgreSQL doesn't allow nested transactions.
I don't know if the with closing(con.connection.cursor()) as c
expressions each open a new connection to the DB. If they do, they won't run in the same transaction because AFAIK transactions are always connection-bound.
Assuming that it works as-implemented, I approve it.
This PR
GeoDataFrame.to_postgis(...index=True)
does not create them)replace
action drops the table and recreates it (see to_postgis). Helpful would be, if replace would implement truncate/insert and a not-yet-existing optionrecreate
would drop and create the table...)