summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/postgresql/psycopg2.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2020-04-14 16:39:42 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2020-04-14 16:39:42 -0400
commit447c0750e1f739c4db1d0d20de182c297dc86e36 (patch)
treef3fc94e0871fb34205fc5695f82d882bea554839 /lib/sqlalchemy/dialects/postgresql/psycopg2.py
parentd9b230e78c70c17a6856f4ff3b8380b9ce510702 (diff)
downloadsqlalchemy-447c0750e1f739c4db1d0d20de182c297dc86e36.tar.gz
Set up absolute references for create_engine and related
includes more replacements for create_engine(), Connection, disambiguation of Result from future/baked Change-Id: Icb60a79ee7a6c45ea9056c211ffd1be110da3b5e
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/psycopg2.py')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/psycopg2.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/psycopg2.py b/lib/sqlalchemy/dialects/postgresql/psycopg2.py
index 6d2672bbe..769fbb06a 100644
--- a/lib/sqlalchemy/dialects/postgresql/psycopg2.py
+++ b/lib/sqlalchemy/dialects/postgresql/psycopg2.py
@@ -15,7 +15,7 @@ psycopg2 Connect Arguments
-----------------------------------
psycopg2-specific keyword arguments which are accepted by
-:func:`.create_engine()` are:
+:func:`_sa.create_engine()` are:
* ``server_side_cursors``: Enable the usage of "server side cursors" for SQL
statements which support this feature. What this essentially means from a
@@ -161,7 +161,7 @@ when used with :ref:`multiple parameter
sets <execute_multiple>`, which includes the use of this feature both by the
Core as well as by the ORM for inserts of objects with non-autogenerated
primary key values, by adding the ``executemany_mode`` flag to
-:func:`.create_engine`::
+:func:`_sa.create_engine`::
engine = create_engine(
"postgresql+psycopg2://scott:tiger@host/dbname",
@@ -251,7 +251,7 @@ A second way to affect the client encoding is to set it within Psycopg2
locally. SQLAlchemy will call psycopg2's
:meth:`psycopg2:connection.set_client_encoding` method
on all new connections based on the value passed to
-:func:`.create_engine` using the ``client_encoding`` parameter::
+:func:`_sa.create_engine` using the ``client_encoding`` parameter::
# set_client_encoding() setting;
# works for *all* PostgreSQL versions
@@ -263,11 +263,12 @@ When using the parameter in this way, the psycopg2 driver emits
``SET client_encoding TO 'utf8'`` on the connection explicitly, and works
in all PostgreSQL versions.
-Note that the ``client_encoding`` setting as passed to :func:`.create_engine`
+Note that the ``client_encoding`` setting as passed to
+:func:`_sa.create_engine`
is **not the same** as the more recently added ``client_encoding`` parameter
now supported by libpq directly. This is enabled when ``client_encoding``
is passed directly to ``psycopg2.connect()``, and from SQLAlchemy is passed
-using the :paramref:`.create_engine.connect_args` parameter::
+using the :paramref:`_sa.create_engine.connect_args` parameter::
engine = create_engine(
"postgresql://user:pass@host/dbname",
@@ -288,10 +289,11 @@ SQLAlchemy can also be instructed to skip the usage of the psycopg2
``UNICODE`` extension and to instead utilize its own unicode encode/decode
services, which are normally reserved only for those DBAPIs that don't
fully support unicode directly. Passing ``use_native_unicode=False`` to
-:func:`.create_engine` will disable usage of ``psycopg2.extensions.UNICODE``.
+:func:`_sa.create_engine` will disable usage of ``psycopg2.extensions.
+UNICODE``.
SQLAlchemy will instead encode data itself into Python bytestrings on the way
in and coerce from bytes on the way back,
-using the value of the :func:`.create_engine` ``encoding`` parameter, which
+using the value of the :func:`_sa.create_engine` ``encoding`` parameter, which
defaults to ``utf-8``.
SQLAlchemy's own unicode encode/decode functionality is steadily becoming
obsolete as most DBAPIs now support unicode fully.
@@ -329,7 +331,7 @@ from the ``size_meters`` key as well.
The other solution is to use a positional format; psycopg2 allows use of the
"format" paramstyle, which can be passed to
-:paramref:`.create_engine.paramstyle`::
+:paramref:`_sa.create_engine.paramstyle`::
engine = create_engine(
'postgresql://scott:tiger@localhost:5432/test', paramstyle='format')
@@ -360,7 +362,8 @@ Psycopg2 Transaction Isolation Level
As discussed in :ref:`postgresql_isolation_level`,
all PostgreSQL dialects support setting of transaction isolation level
-both via the ``isolation_level`` parameter passed to :func:`.create_engine`,
+both via the ``isolation_level`` parameter passed to :func:`_sa.create_engine`
+,
as well as the ``isolation_level`` argument used by
:meth:`_engine.Connection.execution_options`. When using the psycopg2 dialect
, these