Python sqlalchemy.__version__() Examples
The following are 16
code examples of sqlalchemy.__version__().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sqlalchemy
, or try the search function
.
Example #1
Source File: test_sqlalchemy_athena.py From PyAthena with MIT License | 6 votes |
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)
Example #2
Source File: __init__.py From n6 with GNU Affero General Public License v3.0 | 6 votes |
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
Example #3
Source File: test_sqlalchemy_athena.py From PyAthenaJDBC with MIT License | 6 votes |
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)
Example #4
Source File: version.py From temboard with PostgreSQL License | 6 votes |
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'], )
Example #5
Source File: test_dialect.py From sqlalchemy with MIT License | 6 votes |
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)
Example #6
Source File: sql.py From recruit with Apache License 2.0 | 5 votes |
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
Example #7
Source File: sql.py From vnpy_crypto with MIT License | 5 votes |
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
Example #8
Source File: log_versions.py From packit-service with MIT License | 5 votes |
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)
Example #9
Source File: sql.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
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
Example #10
Source File: sql.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
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
Example #11
Source File: sql.py From elasticintel with GNU General Public License v3.0 | 5 votes |
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
Example #12
Source File: TS_CodeGen_Objects.py From pyaf with BSD 3-Clause "New" or "Revised" License | 5 votes |
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
Example #13
Source File: TimeSeriesModel.py From pyaf with BSD 3-Clause "New" or "Revised" License | 5 votes |
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;
Example #14
Source File: display_version_info.py From pyaf with BSD 3-Clause "New" or "Revised" License | 5 votes |
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;
Example #15
Source File: test_codegen.py From safrs with GNU General Public License v3.0 | 4 votes |
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())) ) """ )
Example #16
Source File: orm2010.py From sqlalchemy with MIT License | 4 votes |
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)