SILENT KILLERPanel

Current Path: > > opt > cloudlinux > venv > lib64 > python3.11 > site-packages > sqlalchemy > dialects > postgresql


Operation   : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: //opt/cloudlinux/venv/lib64/python3.11/site-packages/sqlalchemy/dialects/postgresql

NameTypeSizeLast ModifiedActions
__pycache__ Directory - -
__init__.py File 2461 bytes April 17 2025 13:10:58.
array.py File 11776 bytes April 17 2025 13:10:58.
base.py File 129248 bytes April 17 2025 13:10:58.
dml.py File 7790 bytes April 17 2025 13:10:58.
ext.py File 7739 bytes April 17 2025 13:10:58.
hstore.py File 12417 bytes April 17 2025 13:10:58.
json.py File 10103 bytes April 17 2025 13:10:58.
pg8000.py File 9722 bytes April 17 2025 13:10:58.
provision.py File 2008 bytes April 17 2025 13:10:58.
psycopg2.py File 37768 bytes April 17 2025 13:10:58.
psycopg2cffi.py File 1657 bytes April 17 2025 13:10:58.
pygresql.py File 8129 bytes April 17 2025 13:10:58.
pypostgresql.py File 2915 bytes April 17 2025 13:10:58.
ranges.py File 4622 bytes April 17 2025 13:10:58.
zxjdbc.py File 1415 bytes April 17 2025 13:10:58.

Reading File: //opt/cloudlinux/venv/lib64/python3.11/site-packages/sqlalchemy/dialects/postgresql/pypostgresql.py

# postgresql/pypostgresql.py
# Copyright (C) 2005-2021 the SQLAlchemy authors and contributors
# <see AUTHORS file>
#
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""
.. dialect:: postgresql+pypostgresql
    :name: py-postgresql
    :dbapi: pypostgresql
    :connectstring: postgresql+pypostgresql://user:password@host:port/dbname[?key=value&key=value...]
    :url: http://python.projects.pgfoundry.org/

.. note::

    The pypostgresql dialect is **not tested as part of SQLAlchemy's continuous
    integration** and may have unresolved issues.  The recommended PostgreSQL
    driver is psycopg2.


"""  # noqa

from .base import PGDialect
from .base import PGExecutionContext
from ... import processors
from ... import types as sqltypes
from ... import util


class PGNumeric(sqltypes.Numeric):
    def bind_processor(self, dialect):
        return processors.to_str

    def result_processor(self, dialect, coltype):
        if self.asdecimal:
            return None
        else:
            return processors.to_float


class PGExecutionContext_pypostgresql(PGExecutionContext):
    pass


class PGDialect_pypostgresql(PGDialect):
    driver = "pypostgresql"

    supports_unicode_statements = True
    supports_unicode_binds = True
    description_encoding = None
    default_paramstyle = "pyformat"

    # requires trunk version to support sane rowcounts
    # TODO: use dbapi version information to set this flag appropriately
    supports_sane_rowcount = True
    supports_sane_multi_rowcount = False

    execution_ctx_cls = PGExecutionContext_pypostgresql
    colspecs = util.update_copy(
        PGDialect.colspecs,
        {
            sqltypes.Numeric: PGNumeric,
            # prevents PGNumeric from being used
            sqltypes.Float: sqltypes.Float,
        },
    )

    @classmethod
    def dbapi(cls):
        from postgresql.driver import dbapi20

        return dbapi20

    _DBAPI_ERROR_NAMES = [
        "Error",
        "InterfaceError",
        "DatabaseError",
        "DataError",
        "OperationalError",
        "IntegrityError",
        "InternalError",
        "ProgrammingError",
        "NotSupportedError",
    ]

    @util.memoized_property
    def dbapi_exception_translation_map(self):
        if self.dbapi is None:
            return {}

        return dict(
            (getattr(self.dbapi, name).__name__, name)
            for name in self._DBAPI_ERROR_NAMES
        )

    def create_connect_args(self, url):
        opts = url.translate_connect_args(username="user")
        if "port" in opts:
            opts["port"] = int(opts["port"])
        else:
            opts["port"] = 5432
        opts.update(url.query)
        return ([], opts)

    def is_disconnect(self, e, connection, cursor):
        return "connection is closed" in str(e)


dialect = PGDialect_pypostgresql

SILENT KILLER Tool