当前位置: 首页>>代码示例>>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;未经允许,请勿转载。