本文整理匯總了Python中sqlalchemy.util.py2k方法的典型用法代碼示例。如果您正苦於以下問題:Python util.py2k方法的具體用法?Python util.py2k怎麽用?Python util.py2k使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sqlalchemy.util
的用法示例。
在下文中一共展示了util.py2k方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_view_definition
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import py2k [as 別名]
def get_view_definition(self, connection, view_name, schema=None,
resolve_synonyms=False, dblink='', **kw):
info_cache = kw.get('info_cache')
(view_name, schema, dblink, synonym) = \
self._prepare_reflection_args(connection, view_name, schema,
resolve_synonyms, dblink,
info_cache=info_cache)
params = {'view_name': view_name}
text = "SELECT text FROM all_views WHERE view_name=:view_name"
if schema is not None:
text += " AND owner = :schema"
params['schema'] = schema
rp = connection.execute(sql.text(text), **params).scalar()
if rp:
if util.py2k:
rp = rp.decode(self.encoding)
return rp
else:
return None
示例2: get_table_names
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import py2k [as 別名]
def get_table_names(self, connection, schema=None, **kw):
if schema is None:
schema = self.default_schema_name
TABLE_SQL = text("""
SELECT o.name AS name
FROM sysobjects o JOIN sysusers u ON o.uid = u.uid
WHERE u.name = :schema_name
AND o.type = 'U'
""")
if util.py2k:
if isinstance(schema, unicode):
schema = schema.encode("ascii")
tables = connection.execute(TABLE_SQL, schema_name=schema)
return [t["name"] for t in tables]
示例3: get_view_names
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import py2k [as 別名]
def get_view_names(self, connection, schema=None, **kw):
if schema is None:
schema = self.default_schema_name
VIEW_SQL = text("""
SELECT o.name AS name
FROM sysobjects o JOIN sysusers u ON o.uid = u.uid
WHERE u.name = :schema_name
AND o.type = 'V'
""")
if util.py2k:
if isinstance(schema, unicode):
schema = schema.encode("ascii")
views = connection.execute(VIEW_SQL, schema_name=schema)
return [v["name"] for v in views]
示例4: _expect_failure
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import py2k [as 別名]
def _expect_failure(self, config, ex, combination, name="block"):
for fail in self.fails:
if self._check_combinations(combination, fail) and fail(config):
if sqla_util.py2k:
str_ex = unicode(ex).encode( # noqa: F821
"utf-8", errors="ignore"
)
else:
str_ex = str(ex)
print(
(
"%s failed as expected (%s): %s "
% (name, fail._as_string(config), str_ex)
)
)
break
else:
util.raise_from_cause(ex)
示例5: get_view_definition
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import py2k [as 別名]
def get_view_definition(self, connection, view_name, schema=None, **kw):
if schema is None:
schema = self.default_schema_name
VIEW_DEF_SQL = text("""
SELECT c.text
FROM syscomments c JOIN sysobjects o ON c.id = o.id
WHERE o.name = :view_name
AND o.type = 'V'
""")
if util.py2k:
if isinstance(view_name, unicode):
view_name = view_name.encode("ascii")
view = connection.execute(VIEW_DEF_SQL, view_name=view_name)
return view.scalar()
示例6: get_table_names
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import py2k [as 別名]
def get_table_names(self, connection, schema=None, **kw):
if schema is None:
schema = self.default_schema_name
TABLE_SQL = text(
"""
SELECT o.name AS name
FROM sysobjects o JOIN sysusers u ON o.uid = u.uid
WHERE u.name = :schema_name
AND o.type = 'U'
"""
)
if util.py2k:
if isinstance(schema, unicode): # noqa
schema = schema.encode("ascii")
tables = connection.execute(TABLE_SQL, schema_name=schema)
return [t["name"] for t in tables]
示例7: get_view_definition
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import py2k [as 別名]
def get_view_definition(self, connection, view_name, schema=None, **kw):
if schema is None:
schema = self.default_schema_name
VIEW_DEF_SQL = text(
"""
SELECT c.text
FROM syscomments c JOIN sysobjects o ON c.id = o.id
WHERE o.name = :view_name
AND o.type = 'V'
"""
)
if util.py2k:
if isinstance(view_name, unicode): # noqa
view_name = view_name.encode("ascii")
view = connection.execute(VIEW_DEF_SQL, view_name=view_name)
return view.scalar()
示例8: get_view_names
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import py2k [as 別名]
def get_view_names(self, connection, schema=None, **kw):
if schema is None:
schema = self.default_schema_name
VIEW_SQL = text(
"""
SELECT o.name AS name
FROM sysobjects o JOIN sysusers u ON o.uid = u.uid
WHERE u.name = :schema_name
AND o.type = 'V'
"""
)
if util.py2k:
if isinstance(schema, unicode): # noqa
schema = schema.encode("ascii")
views = connection.execute(VIEW_SQL, schema_name=schema)
return [v["name"] for v in views]
示例9: unicode_ddl
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import py2k [as 別名]
def unicode_ddl(self):
"""Target driver must support some degree of non-ascii symbol names."""
# TODO: expand to exclude MySQLdb versions w/ broken unicode
return skip_if(
[
no_support("oracle", "FIXME: no support in database?"),
no_support("sybase", "FIXME: guessing, needs confirmation"),
no_support("mssql+pymssql", "no FreeTDS support"),
LambdaPredicate(
lambda config: against(config, "mysql+mysqlconnector")
and config.db.dialect._mysqlconnector_version_info > (2, 0)
and util.py2k,
"bug in mysqlconnector 2.0",
),
exclude(
"mysql", "<", (4, 1, 1), "no unicode connection support"
),
]
)
示例10: normalize_name
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import py2k [as 別名]
def normalize_name(self, name):
if name is None:
return None
if util.py2k:
if isinstance(name, str):
name = name.decode(self.encoding)
if name.upper() == name and not \
self.identifier_preparer._requires_quotes(name.lower()):
return name.lower()
elif name.lower() == name:
return quoted_name(name, quote=True)
else:
return name