當前位置: 首頁>>代碼示例>>Python>>正文


Python sqlalchemy.__version__方法代碼示例

本文整理匯總了Python中sqlalchemy.__version__方法的典型用法代碼示例。如果您正苦於以下問題:Python sqlalchemy.__version__方法的具體用法?Python sqlalchemy.__version__怎麽用?Python sqlalchemy.__version__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sqlalchemy的用法示例。


在下文中一共展示了sqlalchemy.__version__方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_reflect_table_include_columns

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import __version__ [as 別名]
def test_reflect_table_include_columns(self, engine, conn):
        one_row_complex = Table("one_row_complex", MetaData(bind=engine))
        version = float(
            re.search(r"^([\d]+\.[\d]+)\..+", sqlalchemy.__version__).group(1)
        )
        if version <= 1.2:
            engine.dialect.reflecttable(
                conn, one_row_complex, include_columns=["col_int"], exclude_columns=[]
            )
        else:
            # https://docs.sqlalchemy.org/en/13/changelog/changelog_13.html#
            # change-64ac776996da1a5c3e3460b4c0f0b257
            engine.dialect.reflecttable(
                conn,
                one_row_complex,
                include_columns=["col_int"],
                exclude_columns=[],
                resolve_fks=True,
            )
        self.assertEqual(len(one_row_complex.c), 1)
        self.assertIsNotNone(one_row_complex.c.col_int)
        self.assertRaises(AttributeError, lambda: one_row_complex.c.col_tinyint) 
開發者ID:laughingman7743,項目名稱:PyAthena,代碼行數:24,代碼來源:test_sqlalchemy_athena.py

示例2: ensure_sqlalchemy_supports_utf8mb4

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import __version__ [as 別名]
def ensure_sqlalchemy_supports_utf8mb4():
    import functools

    import sqlalchemy
    from sqlalchemy.dialects.mysql.base import _DecodingRowProxy as mysql_DecodingRowProxy

    if sqlalchemy.__version__ >= '1.':
        return

    if getattr(mysql_DecodingRowProxy, '_n6_monkeypatched_to_enable_utf8mb4', False):
        return

    # utf8mb4-support related fix (~ backported from SQLAlchemy 1.0.0b2,
    # see: https://github.com/sqlalchemy/sqlalchemy/issues/2771)
    @functools.wraps(mysql_DecodingRowProxy.__init__)
    def __init__(self, rowproxy, charset):
        self.rowproxy = rowproxy
        self.charset = ('utf8' if charset == 'utf8mb4' else charset)

    mysql_DecodingRowProxy.__init__ = __init__
    mysql_DecodingRowProxy._n6_monkeypatched_to_enable_utf8mb4 = True 
開發者ID:CERT-Polska,項目名稱:n6,代碼行數:23,代碼來源:__init__.py

示例3: test_reflect_table_include_columns

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import __version__ [as 別名]
def test_reflect_table_include_columns(self, engine, conn):
        one_row_complex = Table("one_row_complex", MetaData(bind=engine))
        version = float(
            re.search(r"^([\d]+\.[\d]+)\..+", sqlalchemy.__version__).group(1)
        )
        if version <= 1.2:
            engine.dialect.reflecttable(
                conn, one_row_complex, include_columns=["col_int"], exclude_columns=[],
            )
        else:
            engine.dialect.reflecttable(
                conn,
                one_row_complex,
                include_columns=["col_int"],
                exclude_columns=[],
                resolve_fks=True,
            )
        self.assertEqual(len(one_row_complex.c), 1)
        self.assertIsNotNone(one_row_complex.c.col_int)
        self.assertRaises(AttributeError, lambda: one_row_complex.c.col_tinyint) 
開發者ID:laughingman7743,項目名稱:PyAthenaJDBC,代碼行數:22,代碼來源:test_sqlalchemy_athena.py

示例4: inspect_versions

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import __version__ [as 別名]
def inspect_versions():
    from alembic import __version__ as alembic_version
    from psycopg2 import __version__ as psycopg2_version
    from tornado import version as tornado_version
    from sqlalchemy import __version__ as sqlalchemy_version

    with open('/etc/os-release') as fo:
        distinfos = parse_lsb_release(fo)

    return dict(
        temboard=__version__,
        alembic=alembic_version,
        psycopg2=psycopg2_version,
        python=python_version(),
        pythonbin=sys.executable,
        tornado=tornado_version,
        sqlalchemy=sqlalchemy_version,
        distname=distinfos['NAME'],
        distversion=distinfos['VERSION'],
    ) 
開發者ID:dalibo,項目名稱:temboard,代碼行數:22,代碼來源:version.py

示例5: test_ident_length_in_13_is_30

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import __version__ [as 別名]
def test_ident_length_in_13_is_30(self):
        from sqlalchemy import __version__

        m = re.match(r"(\d+)\.(\d+)(?:\.(\d+))?", __version__)
        version = tuple(int(x) for x in m.group(1, 2, 3) if x is not None)
        if version >= (1, 4):
            length = 128
        else:
            length = 30

        eq_(oracle.OracleDialect.max_identifier_length, length)

        dialect = self._dialect((12, 2, 0))
        conn = mock.Mock(
            exec_driver_sql=mock.Mock(
                return_value=mock.Mock(scalar=lambda: "12.2.0")
            )
        )
        dialect.initialize(conn)
        eq_(dialect.server_version_info, (12, 2, 0))
        eq_(
            dialect._get_effective_compat_server_version_info(conn), (12, 2, 0)
        )
        eq_(dialect.max_identifier_length, length) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:26,代碼來源:test_dialect.py

示例6: _is_sqlalchemy_connectable

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import __version__ [as 別名]
def _is_sqlalchemy_connectable(con):
    global _SQLALCHEMY_INSTALLED
    if _SQLALCHEMY_INSTALLED is None:
        try:
            import sqlalchemy
            _SQLALCHEMY_INSTALLED = True

            from distutils.version import LooseVersion
            ver = sqlalchemy.__version__
            # For sqlalchemy versions < 0.8.2, the BIGINT type is recognized
            # for a sqlite engine, which results in a warning when trying to
            # read/write a DataFrame with int64 values. (GH7433)
            if LooseVersion(ver) < LooseVersion('0.8.2'):
                from sqlalchemy import BigInteger
                from sqlalchemy.ext.compiler import compiles

                @compiles(BigInteger, 'sqlite')
                def compile_big_int_sqlite(type_, compiler, **kw):
                    return 'INTEGER'
        except ImportError:
            _SQLALCHEMY_INSTALLED = False

    if _SQLALCHEMY_INSTALLED:
        import sqlalchemy
        return isinstance(con, sqlalchemy.engine.Connectable)
    else:
        return False 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:29,代碼來源:sql.py

示例7: log_job_versions

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import __version__ [as 別名]
def log_job_versions():
    """Log essential package versions before running a job."""
    package_versions = [
        ("OGR", ogr_version),
        ("Packit Service", ps_version),
        ("SQL Alchemy", sqlal_version),
        # NOTE: Can't log packit's version for now because it does not provide one.
    ]
    log_package_versions(package_versions) 
開發者ID:packit-service,項目名稱:packit-service,代碼行數:11,代碼來源:log_versions.py

示例8: _is_sqlalchemy_connectable

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import __version__ [as 別名]
def _is_sqlalchemy_connectable(con):
    global _SQLALCHEMY_INSTALLED
    if _SQLALCHEMY_INSTALLED is None:
        try:
            import sqlalchemy
            _SQLALCHEMY_INSTALLED = True

            from distutils.version import LooseVersion
            ver = LooseVersion(sqlalchemy.__version__)
            # For sqlalchemy versions < 0.8.2, the BIGINT type is recognized
            # for a sqlite engine, which results in a warning when trying to
            # read/write a DataFrame with int64 values. (GH7433)
            if ver < '0.8.2':
                from sqlalchemy import BigInteger
                from sqlalchemy.ext.compiler import compiles

                @compiles(BigInteger, 'sqlite')
                def compile_big_int_sqlite(type_, compiler, **kw):
                    return 'INTEGER'
        except ImportError:
            _SQLALCHEMY_INSTALLED = False

    if _SQLALCHEMY_INSTALLED:
        import sqlalchemy
        return isinstance(con, sqlalchemy.engine.Connectable)
    else:
        return False 
開發者ID:nccgroup,項目名稱:Splunking-Crime,代碼行數:29,代碼來源:sql.py

示例9: __init__

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import __version__ [as 別名]
def __init__(self, iDSN = None, iDialect = None):
        self.mDebug = False;
        
        print("CREATING_DATABASE_BACKEND_DSN_DIALECT", sqlalchemy.__version__, iDSN, iDialect);
        self.mDSN = iDSN;
        self.mDialectString = iDialect;
        
        # firebird  __init__.py  mssql  mysql  oracle  postgresql  sqlite  sybase
        self.KNOWN_DIALECTS = {};
        self.KNOWN_DIALECTS [ "firebird" ] = sqlalchemy.dialects.firebird.dialect()
        self.KNOWN_DIALECTS [ "mssql" ] = sqlalchemy.dialects.mssql.dialect()
        self.KNOWN_DIALECTS [ "mysql" ] = sqlalchemy.dialects.mysql.dialect()
        self.KNOWN_DIALECTS [ "oracle" ] = sqlalchemy.dialects.oracle.dialect()
        self.KNOWN_DIALECTS [ "postgresql" ] = sqlalchemy.dialects.postgresql.dialect()
        self.KNOWN_DIALECTS [ "sqlite" ] = sqlalchemy.dialects.sqlite.dialect()
        self.KNOWN_DIALECTS [ "sybase" ] = sqlalchemy.dialects.sybase.dialect()

        self.mMeta = None;
        self.mEngine = None;
        self.mConnection = None;
        self.mDialect = None;

        self.initializeEngine();

        self.mShortLabels = {};
        pass 
開發者ID:antoinecarme,項目名稱:pyaf,代碼行數:28,代碼來源:TS_CodeGen_Objects.py

示例10: getVersions

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import __version__ [as 別名]
def getVersions(self):
        
        import os, platform, pyaf
        lVersionDict = {};
        lVersionDict["PyAF_version"] = pyaf.__version__;
        lVersionDict["system_platform"] = platform.platform();
        lVersionDict["system_uname"] = platform.uname();
        lVersionDict["system_processor"] = platform.processor();
        lVersionDict["python_implementation"] = platform.python_implementation();
        lVersionDict["python_version"] = platform.python_version();

        import sklearn
        lVersionDict["sklearn_version"] = sklearn.__version__;

        import pandas as pd
        lVersionDict["pandas_version"] = pd.__version__;
    
        import numpy as np
        lVersionDict["numpy_version"] = np.__version__;
    
        import scipy as sc
        lVersionDict["scipy_version"] = sc.__version__;

        import matplotlib
        lVersionDict["matplotlib_version"] = matplotlib.__version__

        import pydot
        lVersionDict["pydot_version"] = pydot.__version__

        import sqlalchemy
        lVersionDict["sqlalchemy_version"] = sqlalchemy.__version__

        # print([(k, lVersionDict[k]) for k in sorted(lVersionDict)]);
        return lVersionDict; 
開發者ID:antoinecarme,項目名稱:pyaf,代碼行數:36,代碼來源:TimeSeriesModel.py

示例11: getVersions

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import __version__ [as 別名]
def getVersions():
        
    import os, platform, pyaf
    lVersionDict = {};
    lVersionDict["PyAF_version"] = pyaf.__version__;
    lVersionDict["system_platform"] = platform.platform();
    lVersionDict["system_uname"] = platform.uname();
    lVersionDict["system_processor"] = platform.processor();
    lVersionDict["python_implementation"] = platform.python_implementation();
    lVersionDict["python_version"] = platform.python_version();
    
    import sklearn
    lVersionDict["sklearn_version"] = sklearn.__version__;
    
    import pandas as pd
    lVersionDict["pandas_version"] = pd.__version__;
    
    import numpy as np
    lVersionDict["numpy_version"] = np.__version__;
    
    import scipy as sc
    lVersionDict["scipy_version"] = sc.__version__;
    
    import matplotlib
    lVersionDict["matplotlib_version"] = matplotlib.__version__

    import pydot
    lVersionDict["pydot_version"] = pydot.__version__

    import sqlalchemy
    lVersionDict["sqlalchemy_version"] = sqlalchemy.__version__
    
    print([(k, lVersionDict[k]) for k in sorted(lVersionDict)]);
    return lVersionDict; 
開發者ID:antoinecarme,項目名稱:pyaf,代碼行數:36,代碼來源:display_version_info.py

示例12: test_arrays

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import __version__ [as 別名]
def test_arrays(metadata):
    Table(
        "simple_items",
        metadata,
        Column("dp_array", postgresql.ARRAY(postgresql.DOUBLE_PRECISION(precision=53))),
        Column("int_array", postgresql.ARRAY(INTEGER)),
    )

    if sqlalchemy.__version__ < "1.1":
        assert (
            generate_code(metadata)
            == """\
# coding: utf-8
from sqlalchemy import Column, Float, Integer, MetaData, Table
from sqlalchemy.dialects.postgresql.base import ARRAY

metadata = MetaData()


t_simple_items = Table(
    'simple_items', metadata,
    Column('dp_array', ARRAY(Float(precision=53))),
    Column('int_array', ARRAY(Integer()))
)
"""
        )
    else:
        assert (
            generate_code(metadata)
            == """\
# coding: utf-8
from sqlalchemy import ARRAY, Column, Float, Integer, MetaData, Table

metadata = MetaData()


t_simple_items = Table(
    'simple_items', metadata,
    Column('dp_array', ARRAY(Float(precision=53))),
    Column('int_array', ARRAY(Integer()))
)
"""
        ) 
開發者ID:thomaxxl,項目名稱:safrs,代碼行數:45,代碼來源:test_codegen.py

示例13: run_with_profile

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import __version__ [as 別名]
def run_with_profile(runsnake=False, dump=False):
    import cProfile
    import pstats

    filename = "orm2010.profile"

    if os.path.exists("orm2010.profile"):
        os.remove("orm2010.profile")

    def status(msg):
        print(msg)

    cProfile.runctx(
        # "runit_persist(status)",
        "runit_persist(status); runit_query_runs(status)",
        globals(),
        locals(),
        filename,
    )
    stats = pstats.Stats(filename)

    counts_by_methname = dict(
        (key[2], stats.stats[key][0]) for key in stats.stats
    )

    print("SQLA Version: %s" % __version__)
    print("Total calls %d" % stats.total_calls)
    print("Total cpu seconds: %.2f" % stats.total_tt)
    print(
        "Total execute calls: %d"
        % counts_by_methname[
            "<method 'execute' of 'sqlite3.Cursor' " "objects>"
        ]
    )
    print(
        "Total executemany calls: %d"
        % counts_by_methname.get(
            "<method 'executemany' of 'sqlite3.Cursor' " "objects>", 0
        )
    )

    if dump:
        #        stats.sort_stats("nfl")
        stats.sort_stats("cumtime", "calls")
        stats.print_stats()
    #        stats.print_callers()

    if runsnake:
        os.system("runsnake %s" % filename) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:51,代碼來源:orm2010.py


注:本文中的sqlalchemy.__version__方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。