本文整理汇总了Python中sqlalchemy.testing.exclusions.only_if函数的典型用法代码示例。如果您正苦于以下问题:Python only_if函数的具体用法?Python only_if怎么用?Python only_if使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了only_if函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: bulletproof_pickle
def bulletproof_pickle(self):
from sqlalchemy.util import pickle
return only_if(
lambda: pickle.__name__ == 'cPickle' and \
sys.version_info < (3, 0) and not util.pypy,
"Needs Python 2.x cPickle"
)
示例2: mod_operator_as_percent_sign
def mod_operator_as_percent_sign(self):
"""target database must use a plain percent '%' as the 'modulus'
operator."""
return only_if(
['mysql', 'sqlite', 'postgresql+psycopg2', 'mssql']
)
示例3: non_broken_pickle
def non_broken_pickle(self):
from sqlalchemy.util import pickle
return only_if(
lambda: not util.pypy and pickle.__name__ == 'cPickle'
or sys.version_info >= (3, 2),
"Needs cPickle+cPython or newer Python 3 pickle"
)
示例4: ctes_on_dml
def ctes_on_dml(self):
"""target database supports CTES which consist of INSERT, UPDATE
or DELETE *within* the CTE, e.g. WITH x AS (UPDATE....)"""
return only_if(
['postgresql']
)
示例5: ctes_on_dml
def ctes_on_dml(self):
"""target database supports CTES which consist of INSERT, UPDATE
or DELETE"""
return only_if(
['postgresql']
)
示例6: mysql_ngram_fulltext
def mysql_ngram_fulltext(self):
def check(config):
return (
against(config, "mysql")
and not config.db.dialect._is_mariadb
and config.db.dialect.server_version_info >= (5, 7)
)
return only_if(check)
示例7: _has_pg_extension
def _has_pg_extension(self, name):
def check(config):
if not against(config, "postgresql"):
return False
count = config.db.scalar(
"SELECT count(*) FROM pg_extension "
"WHERE extname='%s'" % name)
return bool(count)
return only_if(check, "needs %s extension" % name)
示例8: mysql_non_strict
def mysql_non_strict(self):
def check(config):
if not against(config, 'mysql'):
return False
row = config.db.execute("show variables like 'sql_mode'").first()
return not row or "STRICT_TRANS_TABLES" not in row[1]
return only_if(check)
示例9: mysql_zero_date
def mysql_zero_date(self):
def check(config):
if not against(config, 'mysql'):
return False
row = config.db.execute("show variables like 'sql_mode'").first()
return not row or "NO_ZERO_DATE" not in row[1]
return only_if(check)
示例10: hstore
def hstore(self):
def check_hstore():
if not against("postgresql"):
return False
try:
self.db.execute("SELECT 'a=>1,a=>2'::hstore;")
return True
except:
return False
return only_if(check_hstore)
示例11: hstore
def hstore(self):
def check_hstore(config):
if not against(config, "postgresql"):
return False
try:
config.db.execute("SELECT 'a=>1,a=>2'::hstore;")
return True
except Exception:
return False
return only_if(check_hstore)
示例12: range_types
def range_types(self):
def check_range_types():
if not against("postgresql+psycopg2"):
return False
try:
self.db.execute("select '[1,2)'::int4range;")
# only supported in psycopg 2.5+
from psycopg2.extras import NumericRange
return True
except:
return False
return only_if(check_range_types)
示例13: range_types
def range_types(self):
def check_range_types(config):
if not against(
config,
["postgresql+psycopg2", "postgresql+psycopg2cffi"]):
return False
try:
config.db.scalar("select '[1,2)'::int4range;")
return True
except:
return False
return only_if(check_range_types)
示例14: pyodbc_fast_executemany
def pyodbc_fast_executemany(self):
def has_fastexecutemany(config):
if not against(config, "mssql+pyodbc"):
return False
if config.db.dialect._dbapi_version() < (4, 0, 19):
return False
with config.db.connect() as conn:
drivername = conn.connection.connection.getinfo(
config.db.dialect.dbapi.SQL_DRIVER_NAME)
# on linux this is 'libmsodbcsql-13.1.so.9.2'.
# don't know what it is on windows
return "msodbc" in drivername
return only_if(
has_fastexecutemany,
"only on pyodbc > 4.0.19 w/ msodbc driver")
示例15: mysql_non_strict
def mysql_non_strict(self):
def check(config):
row = config.db.execute("show variables like 'sql_mode'").first()
return not row or "STRICT" not in row[1]
return only_if(check)