Deprecated twisted.enterprise.util

Recently updated Twisted from version 11 to version 12. The twisted.enterprise.util module was found to no longer exist.

I used this:

from twisted.enterprise import adbapi, util as dbutil

query = "select userid, password from user where username = %s" % (
      dbutil.quote(credentials.username, "char"))


Now do we need to use a third party library?


source to share

1 answer

The correct way is "binding parameters". This keeps the SQL separate from the data and removes the entire category of misjudgment errors. The way to use bind parameters is to pass the SQL string as a separate argument from the SQL data. Using DB-API 2.0 this means something like:

cursor.execute("SELECT foo FROM bar WHERE baz = ?", (3,))


Using ADBAPI, this means something very similar:

connpool.runQuery("SELECT foo FROM bar WHERE baz = ?", (3,))


Different database adapters use different syntaxes for "?" part. The `paramstyle 'attribute of a DB-API 2.0 module tells you which syntax a particular module is using. See DB-API 2.0 PEP ( ) for details.




All Articles