2017-01-26 7 views
1

In der Dokumentation psycopg2 verweist es auf eine sql Eigenschaft voller Spaß Güte für sicher SQL-Strings erstellen. Doch mein auf Python 3 installieren, das von PyPI neuesten sein soll, enthält kein solches Attribut:Was ist mit psycopg2.sql passiert?

from psycopg2 import sql 
# ImportError: cannot import name 'sql' 

import psycopg2 
print(dir(psycopg2)) # no mention of sql, although dir is not complete 

# in the REPL 
help(psycopg2) # no mention of the sql submodule that I saw 

So wie kann ich sicher SQL-Strings, ohne es konstruieren (ich habe null Interesse an SQLAlchemy)? Oder sollte ich das noch haben und die Tatsache, dass es fehlt, ist besorgniserregend?

Antwort

6

Es ist neu in Psycopg2 2.7. Was ist deine Version?

>>> psycopg2.__version__ 
'2.6.2 (dt dec pq3 ext lo64)' 

http://initd.org/psycopg/docs/sql.html

+0

gerade geprüft 'pip freeze', ich bin auf 2.6.2. Hoppla. –