pg8000 will encode / decode string values between it and the server using the PostgreSQL client_encoding parameter; by default this is the value in the postgresql.conf file, which often defaults to SQL_ASCII. Typically, this can be changed to utf-8, as a more useful default:
#client_encoding = sql_ascii # actually, defaults to database # encoding client_encoding = utf8
The client_encoding can be overridden for a session by executing the SQL:
SET CLIENT_ENCODING TO 'utf8';
SQLAlchemy will execute this SQL on all new connections based on the value
passed to _sa.create_engine
using the client_encoding parameter:
engine = create_engine( "postgresql+pg8000://user:pass@host/dbname", client_encoding='utf8')
pg8000 accepts a Python SSLContext object which may be specified using the :paramref:`_sa.create_engine.connect_args` dictionary:
import ssl ssl_context = ssl.create_default_context() engine = sa.create_engine( "postgresql+pg8000://scott:tiger@192.168.0.199/test", connect_args={"ssl_context": ssl_context}, )
If the server uses an automatically-generated certificate that is self-signed or does not match the host name (as seen from the client), it may also be necessary to disable hostname checking:
import ssl ssl_context = ssl.create_default_context() ssl_context.check_hostname = False ssl_context.verify_mode = ssl.CERT_NONE engine = sa.create_engine( "postgresql+pg8000://scott:tiger@192.168.0.199/test", connect_args={"ssl_context": ssl_context}, )
The pg8000 dialect offers the same isolation level settings as that of the :ref:`psycopg2 <psycopg2_isolation_level>` dialect:
Class | _PGARRAY |
Undocumented |
Class | _PGBigInteger |
Undocumented |
Class | _PGBoolean |
Undocumented |
Class | _PGEnum |
Undocumented |
Class | _PGInteger |
Undocumented |
Class | _PGInterval |
Undocumented |
Class | _PGJSON |
Undocumented |
Class | _PGJSONB |
Undocumented |
Class | _PGJSONIndexType |
Undocumented |
Class | _PGJSONIntIndexType |
Undocumented |
Class | _PGJSONPathType |
Undocumented |
Class | _PGJSONStrIndexType |
Undocumented |
Class | _PGNullType |
Undocumented |
Class | _PGNumeric |
Undocumented |
Class | _PGNumericNoBind |
Undocumented |
Class | _PGSmallInteger |
Undocumented |
Class | _PGTime |
Undocumented |
Class | _PGTimeStamp |
Undocumented |
Class | _PGUUID |
Undocumented |
Class | PGCompiler_pg8000 |
Undocumented |
Class | PGDialect_pg8000 |
Undocumented |
Class | PGExecutionContext_pg8000 |
Undocumented |
Class | PGIdentifierPreparer_pg8000 |
Undocumented |
Class | ServerSideCursor |
Undocumented |
Variable | _server_side_id |
Undocumented |