[DB-SIG] Typing / Protocol for DBAPI-compatible connections and cursors
John Stevenson - BGS
jostev at bgs.ac.uk
Fri Dec 2 12:47:46 EST 2022
Hi,
Is there a way to do type hints for a generic DBAPI-compatible connection and cursor? Our ETL Helper tool uses cx_Oracle, psycopg2 and sqlite3 connections interchangeably and it would be useful to have a generic type instead explicitly using the classes from each driver.
As far as I can see from Google, one way to achieve this would by using Protocols, as defined in PEP 544 (https://peps.python.org/pep-0544/). Is there an "official" PEP 249 DBA API 2.0 protocol anywhere?
Thanks,
John
p.s. ETL Helper is a library we developed to make it easier for our DBAs to use Python to transfer data. https://pypi.org/project/etlhelper/
This email and any attachments are intended solely for the use of the named recipients. If you are not the intended recipient you must not use, disclose, copy or distribute this email or any of its attachments and should notify the sender immediately and delete this email from your system. UK Research and Innovation (UKRI) has taken every reasonable precaution to minimise risk of this email or any attachments containing viruses or malware but the recipient should carry out its own virus and malware checks before opening the attachments. UKRI does not accept any liability for any losses or damages which the recipient may sustain due to presence of any viruses.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/db-sig/attachments/20221202/ca92b836/attachment.html>
More information about the DB-SIG
mailing list