SILENT KILLERPanel

Current Path: > > opt > cloudlinux > venv > lib > > python3.11 > site-packages > > sqlalchemy > dialects > mysql


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/lib//python3.11/site-packages//sqlalchemy/dialects/mysql

NameTypeSizeLast ModifiedActions
__pycache__ Directory - -
__init__.py File 2056 bytes April 17 2025 13:10:58.
base.py File 107282 bytes April 17 2025 13:10:58.
cymysql.py File 2244 bytes April 17 2025 13:10:58.
dml.py File 4764 bytes April 17 2025 13:10:58.
enumerated.py File 11307 bytes April 17 2025 13:10:58.
gaerdbms.py File 3375 bytes April 17 2025 13:10:58.
json.py File 2045 bytes April 17 2025 13:10:58.
mysqlconnector.py File 7889 bytes April 17 2025 13:10:58.
mysqldb.py File 8504 bytes April 17 2025 13:10:58.
oursql.py File 8086 bytes April 17 2025 13:10:58.
provision.py File 1269 bytes April 17 2025 13:10:58.
pymysql.py File 2720 bytes April 17 2025 13:10:58.
pyodbc.py File 3470 bytes April 17 2025 13:10:58.
reflection.py File 18275 bytes April 17 2025 13:10:58.
types.py File 24589 bytes April 17 2025 13:10:58.
zxjdbc.py File 3970 bytes April 17 2025 13:10:58.

Reading File: //opt/cloudlinux/venv/lib//python3.11/site-packages//sqlalchemy/dialects/mysql/zxjdbc.py

# mysql/zxjdbc.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

r"""

.. dialect:: mysql+zxjdbc
    :name: zxjdbc for Jython
    :dbapi: zxjdbc
    :connectstring: mysql+zxjdbc://<user>:<password>@<hostname>[:<port>]/<database>
    :driverurl: http://dev.mysql.com/downloads/connector/j/

    .. note:: Jython is not supported by current versions of SQLAlchemy.  The
       zxjdbc dialect should be considered as experimental.

Character Sets
--------------

SQLAlchemy zxjdbc dialects pass unicode straight through to the
zxjdbc/JDBC layer. To allow multiple character sets to be sent from the
MySQL Connector/J JDBC driver, by default SQLAlchemy sets its
``characterEncoding`` connection property to ``UTF-8``. It may be
overridden via a ``create_engine`` URL parameter.

"""  # noqa
import re

from .base import BIT
from .base import MySQLDialect
from .base import MySQLExecutionContext
from ... import types as sqltypes
from ... import util
from ...connectors.zxJDBC import ZxJDBCConnector


class _ZxJDBCBit(BIT):
    def result_processor(self, dialect, coltype):
        """Converts boolean or byte arrays from MySQL Connector/J to longs."""

        def process(value):
            if value is None:
                return value
            if isinstance(value, bool):
                return int(value)
            v = 0
            for i in value:
                v = v << 8 | (i & 0xFF)
            value = v
            return value

        return process


class MySQLExecutionContext_zxjdbc(MySQLExecutionContext):
    def get_lastrowid(self):
        cursor = self.create_cursor()
        cursor.execute("SELECT LAST_INSERT_ID()")
        lastrowid = cursor.fetchone()[0]
        cursor.close()
        return lastrowid


class MySQLDialect_zxjdbc(ZxJDBCConnector, MySQLDialect):
    jdbc_db_name = "mysql"
    jdbc_driver_name = "com.mysql.jdbc.Driver"

    execution_ctx_cls = MySQLExecutionContext_zxjdbc

    colspecs = util.update_copy(
        MySQLDialect.colspecs, {sqltypes.Time: sqltypes.Time, BIT: _ZxJDBCBit}
    )

    def _detect_charset(self, connection):
        """Sniff out the character set in use for connection results."""
        # Prefer 'character_set_results' for the current connection over the
        # value in the driver.  SET NAMES or individual variable SETs will
        # change the charset without updating the driver's view of the world.
        #
        # If it's decided that issuing that sort of SQL leaves you SOL, then
        # this can prefer the driver value.
        rs = connection.execute("SHOW VARIABLES LIKE 'character_set%%'")
        opts = {row[0]: row[1] for row in self._compat_fetchall(rs)}
        for key in ("character_set_connection", "character_set"):
            if opts.get(key, None):
                return opts[key]

        util.warn(
            "Could not detect the connection character set.  "
            "Assuming latin1."
        )
        return "latin1"

    def _driver_kwargs(self):
        """return kw arg dict to be sent to connect()."""
        return dict(characterEncoding="UTF-8", yearIsDateType="false")

    def _extract_error_code(self, exception):
        # e.g.: DBAPIError: (Error) Table 'test.u2' doesn't exist
        # [SQLCode: 1146], [SQLState: 42S02] 'DESCRIBE `u2`' ()
        m = re.compile(r"\[SQLCode\: (\d+)\]").search(str(exception.args))
        c = m.group(1)
        if c:
            return int(c)

    def _get_server_version_info(self, connection):
        dbapi_con = connection.connection
        version = []
        r = re.compile(r"[.\-]")
        for n in r.split(dbapi_con.dbversion):
            try:
                version.append(int(n))
            except ValueError:
                version.append(n)
        return tuple(version)


dialect = MySQLDialect_zxjdbc

SILENT KILLER Tool