psycopg2 不声称支持以下autocommit
关键字参数connect
:
connect(dsn=None, database=None, user=None, password=None, host=None, port=None, connection_factory=None, async=False, **kwargs)
Create a new database connection.
The connection parameters can be specified either as a string:
conn = psycopg2.connect("dbname=test user=postgres password=secret")
or using a set of keyword arguments:
conn = psycopg2.connect(database="test", user="postgres", password="secret")
The basic connection parameters are:
- *dbname*: the database name (only in dsn string)
- *database*: the database name (only as keyword argument)
- *user*: user name used to authenticate
- *password*: password used to authenticate
- *host*: database host address (defaults to UNIX socket if not provided)
- *port*: connection port number (defaults to 5432 if not provided)
Using the *connection_factory* parameter a different class or connections
factory can be specified. It should be a callable object taking a dsn
argument.
Using *async*=True an asynchronous connection will be created.
Any other keyword parameter will be passed to the underlying client
library: the list of supported parameter depends on the library version.
当前的 postgresql 文档也没有讨论任何“自动提交”参数:
http://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-CONNSTRING
所以也许问题是这不是为 psycopg2 连接禁用自动提交的正确方法。除此之外,您不会发现关闭自动提交实际上对您有帮助。 adbapi.ConnectionPool
将为您开始并提交显式事务,回避任何autocommit
可能给您的行为模式。