Open irfansharif opened 4 years ago
@irfansharif thanks for filing. Unassigned myself since I am not working on developer docs for the 20.2 cycle (got assigned to geo stuff instead).
@ericharmeling I think this is still your world?
@ericharmeling, @awoods187, this should go into your backlog.
Irfan Sharif (irfansharif) commented:
Re: Build a Python App with CockroachDB and psycopg2
Issue Description
We elide any mention of psycopg2's
autocommit
mode, which is necessary to document for statements executed against CRDB that are decidedly not allowed to be as part of transactions. One example isRESTORE
, using the code snippet linked above but only swapping in the DDL with aRESTORE
statement would fail withpsycopg2.InternalError: RESTORE cannot be used inside a transaction
.Suggested Resolution
I believe the thing we're looking for is https://www.psycopg.org/docs/usage.html#transactions-control. Since
RESTORE
cannot be used as part of the transaction, to address this, we're going to need to setautocommit
. From the psycopg2 doc:I believe this may be more broadly applicable to other DDL commands that aren't entirely safe to be wrapped in txns (though that's something that's currently being worked on on the CRDB side of things)
Jira Issue: DOC-488