This project is archived and is in readonly mode.
assert vs the fine manual
Reported by Psycopg website | May 21st, 2014 @ 06:19 PM
Submitted by: dmaziuk@bmrb.wisc.edu
More of a wishlist I guess, but the docs state that psycopg2 has "connection" class and "cursor" class. If you believe that:
assert isinstance( conn, psycopg2.connection )
AttributeError: 'module' object has no attribute 'connection'
I can of course use 'psycopg2._psycopg.connection' and 'psycopg2._psycopg.cursor, but
1) the API says they should be "Connection" and "Cursor" (note:
proper-cased),
2) sqlite3 does it right, so there's principle of least surprise
there, and
3) your own fine manual is lying.
Not so good...
Comments and changes to this ticket
-
Daniele Varrazzo May 21st, 2014 @ 09:36 PM
- State changed from new to invalid
More of a wishlist I guess, but the docs state that psycopg2 has "connection" class and "cursor" class. If you believe that:
assert isinstance( conn, psycopg2.connection ) AttributeError: 'module' object has no attribute 'connection'
It's not stated in the DBAPI that this is the case. Because originally psycopg was a very strict dbapi module plus a well-defined extension submodules, these class are available from...
I can of course use 'psycopg2._psycopg.connection' and 'psycopg2._psycopg.cursor, but
Of course you could read the manual and discover that the classes are exposed in the
psycopg2.extensions
module;psycopg2._psycopg
is an implementation detail1) the API says they should be "Connection" and "Cursor" (note: proper-cased),
Probably but not really explicitly. I would have liked them uppercase too, but they are that way since 1999 (psycopg largely predates the PEP 8) and don't see any urge in changing them. There can be (and there are) several classes and they cannot be called all the same. That's why the DBAPI demands factory methods instead of publicly accessible classes.
2) sqlite3 does it right, so there's principle of least surprise there, and
don't see how this is relevant
3) your own fine manual is lying.
And why don't you tell where? And why haven't you provided a patch to fix them?
Not so good...
Are you trying to win a niceness contest?
Closing this bug as being filed by a moronic troll. If you have patches to fix anything wrong send them us, otherwise write your own database adapter, mister not-so-good-ellipsis.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
<b>WARNING:</b> the informations in this tracker are archived. Please submit new tickets or comments to <a href="https://github.com/psycopg/psycopg2/issues">the new tracker</a>.
<br/>
Psycopg is the most used PostgreSQL adapter for the Python programming language. At the core it fully implements the Python DB API 2.0 specifications. Several extensions allow access to many of the features offered by PostgreSQL.