What happened to psycopg2.sql?

老子叫甜甜 提交于 2020-03-24 00:43:59

问题


In the psycopg2 docs it references an sql property full of fun goodness for safely constructing SQL strings. Yet my install on python 3, which should be latest from PyPI, contains no such attribute:

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 how can I safely construct SQL strings without it (I have zero interest in SQLAlchemy)? Or should I still have that and the fact that its missing is worrisome?


回答1:


It is new in Psycopg2 2.7. What is your version?

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

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



来源:https://stackoverflow.com/questions/41883389/what-happened-to-psycopg2-sql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!