本文整理汇总了Python中sqlalchemy.util.warn_deprecated函数的典型用法代码示例。如果您正苦于以下问题:Python warn_deprecated函数的具体用法?Python warn_deprecated怎么用?Python warn_deprecated使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了warn_deprecated函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: visit_create_index
def visit_create_index(self, create):
preparer = self.preparer
index = create.element
text = "CREATE "
if index.unique:
text += "UNIQUE "
text += "INDEX %s ON %s (%s)" \
% (preparer.quote(self._validate_identifier(index.name, True), index.quote),
preparer.format_table(index.table),
', '.join([preparer.format_column(c) for c in index.columns]))
if "postgres_where" in index.kwargs:
whereclause = index.kwargs['postgres_where']
util.warn_deprecated("The 'postgres_where' argument has been renamed to 'postgresql_where'.")
elif 'postgresql_where' in index.kwargs:
whereclause = index.kwargs['postgresql_where']
else:
whereclause = None
if whereclause is not None:
compiler = self._compile(whereclause, None)
# this might belong to the compiler class
inlined_clause = str(compiler) % dict(
[(key,bind.value) for key,bind in compiler.binds.iteritems()])
text += " WHERE " + inlined_clause
return text
示例2: visit_create_index
def visit_create_index(self, create):
preparer = self.preparer
index = create.element
text = "CREATE "
if index.unique:
text += "UNIQUE "
text += "INDEX %s ON %s (%s)" \
% (preparer.quote(
self._validate_identifier(index.name, True), index.quote),
preparer.format_table(index.table),
', '.join([preparer.format_column(c)
for c in index.columns]))
if "postgres_where" in index.kwargs:
whereclause = index.kwargs['postgres_where']
util.warn_deprecated(
"The 'postgres_where' argument has been renamed "
"to 'postgresql_where'.")
elif 'postgresql_where' in index.kwargs:
whereclause = index.kwargs['postgresql_where']
else:
whereclause = None
if whereclause is not None:
whereclause = sql_util.expression_as_ddl(whereclause)
where_compiled = self.sql_compiler.process(whereclause)
text += " WHERE " + where_compiled
return text
示例3: dbapi
def dbapi(cls):
warn_deprecated(
"Google Cloud SQL now recommends creating connections via the "
"MySQLdb dialect directly, using the URL format "
"mysql+mysqldb://[email protected]/<dbname>?unix_socket=/cloudsql/"
"<projectid>:<instancename>"
)
# from django:
# http://code.google.com/p/googleappengine/source/
# browse/trunk/python/google/storage/speckle/
# python/django/backend/base.py#118
# see also [ticket:2649]
# see also http://stackoverflow.com/q/14224679/34549
from google.appengine.api import apiproxy_stub_map
if _is_dev_environment():
from google.appengine.api import rdbms_mysqldb
return rdbms_mysqldb
elif apiproxy_stub_map.apiproxy.GetStub('rdbms'):
from google.storage.speckle.python.api import rdbms_apiproxy
return rdbms_apiproxy
else:
from google.storage.speckle.python.api import rdbms_googleapi
return rdbms_googleapi
示例4: get_history
def get_history(obj, key, passive=PASSIVE_OFF):
"""Return a :class:`.History` record for the given object
and attribute key.
:param obj: an object whose class is instrumented by the
attributes package.
:param key: string attribute name.
:param passive: indicates if the attribute should be
loaded from the database if not already present (:attr:`.PASSIVE_NO_FETCH`), and
if the attribute should be not initialized to a blank value otherwise
(:attr:`.PASSIVE_NO_INITIALIZE`). Default is :attr:`PASSIVE_OFF`.
"""
if passive is True:
util.warn_deprecated("Passing True for 'passive' is deprecated. "
"Use attributes.PASSIVE_NO_INITIALIZE")
passive = PASSIVE_NO_INITIALIZE
elif passive is False:
util.warn_deprecated("Passing False for 'passive' is "
"deprecated. Use attributes.PASSIVE_OFF")
passive = PASSIVE_OFF
return get_state_history(instance_state(obj), key, passive)
示例5: compare_values
def compare_values(self, x, y):
if self.comparator:
return self.comparator(x, y)
elif self.mutable and not hasattr(x, '__eq__') and x is not None:
util.warn_deprecated("Objects stored with PickleType when mutable=True must implement __eq__() for reliable comparison.")
return self.pickler.dumps(x, self.protocol) == self.pickler.dumps(y, self.protocol)
else:
return x == y
示例6: dialect_impl
def dialect_impl(self, dialect, **kwargs):
_for_ddl = kwargs.pop("_for_ddl", False)
if _for_ddl and self.length is None:
label = util.to_ascii(_for_ddl is True and "" or (' for column "%s"' % str(_for_ddl)))
util.warn_deprecated(
"Using String type with no length for CREATE TABLE "
"is deprecated; use the Text type explicitly" + label
)
return TypeEngine.dialect_impl(self, dialect, **kwargs)
示例7: __init__
def __init__(
self,
convert_unicode=False,
assert_unicode=False,
encoding="utf-8",
paramstyle=None,
dbapi=None,
implicit_returning=None,
label_length=None,
**kwargs
):
if not getattr(self, "ported_sqla_06", True):
util.warn("The %s dialect is not yet ported to SQLAlchemy 0.6/0.7" % self.name)
self.convert_unicode = convert_unicode
if assert_unicode:
util.warn_deprecated(
"assert_unicode is deprecated. "
"SQLAlchemy emits a warning in all cases where it "
"would otherwise like to encode a Python unicode object "
"into a specific encoding but a plain bytestring is "
"received. "
"This does *not* apply to DBAPIs that coerce Unicode "
"natively."
)
self.encoding = encoding
self.positional = False
self._ischema = None
self.dbapi = dbapi
if paramstyle is not None:
self.paramstyle = paramstyle
elif self.dbapi is not None:
self.paramstyle = self.dbapi.paramstyle
else:
self.paramstyle = self.default_paramstyle
if implicit_returning is not None:
self.implicit_returning = implicit_returning
self.positional = self.paramstyle in ("qmark", "format", "numeric")
self.identifier_preparer = self.preparer(self)
self.type_compiler = self.type_compiler(self)
if label_length and label_length > self.max_identifier_length:
raise exc.ArgumentError(
"Label length of %d is greater than this dialect's"
" maximum identifier length of %d" % (label_length, self.max_identifier_length)
)
self.label_length = label_length
if self.description_encoding == "use_encoding":
self._description_decoder = processors.to_unicode_processor_factory(encoding)
elif self.description_encoding is not None:
self._description_decoder = processors.to_unicode_processor_factory(self.description_encoding)
self._encoder = codecs.getencoder(self.encoding)
self._decoder = processors.to_unicode_processor_factory(self.encoding)
示例8: __init__
def __init__(self, class_, *columns, **kwargs):
if "comparator" in kwargs:
util.warn_deprecated(
"The 'comparator' argument to CompositeProperty is deprecated. Use comparator_factory."
)
kwargs["comparator_factory"] = kwargs["comparator"]
super(CompositeProperty, self).__init__(*columns, **kwargs)
self._col_position_map = util.column_dict((c, i) for i, c in enumerate(columns))
self.composite_class = class_
self.strategy_class = strategies.CompositeColumnLoader
示例9: _pop_deprecated_kwargs
def _pop_deprecated_kwargs(self, kwargs):
auto_setinputsizes = kwargs.pop('auto_setinputsizes', None)
exclude_setinputsizes = kwargs.pop('exclude_setinputsizes', None)
if auto_setinputsizes or exclude_setinputsizes:
util.warn_deprecated(
"auto_setinputsizes and exclude_setinputsizes are deprecated. "
"Modern cx_Oracle only requires that LOB types are part "
"of this behavior, and these parameters no longer have any "
"effect.")
allow_twophase = kwargs.pop('allow_twophase', None)
if allow_twophase is not None:
util.warn.deprecated(
"allow_twophase is deprecated. The cx_Oracle dialect no "
"longer supports two-phase transaction mode."
)
示例10: __init__
def __init__(self, precision=10, scale=2, asdecimal=True, length=None):
"""
Construct a Numeric.
:param precision: the numeric precision for use in DDL ``CREATE TABLE``.
:param scale: the numeric scale for use in DDL ``CREATE TABLE``.
:param asdecimal: default True. If False, values will be
returned as-is from the DB-API, and may be either
``Decimal`` or ``float`` types depending on the DB-API in
use.
"""
if length:
util.warn_deprecated("'length' is deprecated for Numeric. Use 'scale'.")
scale = length
self.precision = precision
self.scale = scale
self.asdecimal = asdecimal
示例11: create_session
def create_session(bind=None, **kwargs):
"""Create a new :class:`~sqlalchemy.orm.session.Session`.
:param bind: optional, a single Connectable to use for all
database access in the created
:class:`~sqlalchemy.orm.session.Session`.
:param \*\*kwargs: optional, passed through to the
:class:`Session` constructor.
:returns: an :class:`~sqlalchemy.orm.session.Session` instance
The defaults of create_session() are the opposite of that of
:func:`sessionmaker`; ``autoflush`` and ``expire_on_commit`` are
False, ``autocommit`` is True. In this sense the session acts
more like the "classic" SQLAlchemy 0.3 session with these.
Usage::
>>> from sqlalchemy.orm import create_session
>>> session = create_session()
It is recommended to use :func:`sessionmaker` instead of
create_session().
"""
if 'transactional' in kwargs:
sa_util.warn_deprecated(
"The 'transactional' argument to sessionmaker() is deprecated; "
"use autocommit=True|False instead.")
if 'autocommit' in kwargs:
raise TypeError('Specify autocommit *or* transactional, not both.')
kwargs['autocommit'] = not kwargs.pop('transactional')
kwargs.setdefault('autoflush', False)
kwargs.setdefault('autocommit', True)
kwargs.setdefault('expire_on_commit', False)
return _Session(bind=bind, **kwargs)
示例12: __init__
def __init__(self,
creator, recycle=-1, echo=None,
use_threadlocal=False,
logging_name=None,
reset_on_return=True,
listeners=None,
events=None,
_dispatch=None):
"""
Construct a Pool.
:param creator: a callable function that returns a DB-API
connection object. The function will be called with
parameters.
:param recycle: If set to non -1, number of seconds between
connection recycling, which means upon checkout, if this
timeout is surpassed the connection will be closed and
replaced with a newly opened connection. Defaults to -1.
:param logging_name: String identifier which will be used within
the "name" field of logging records generated within the
"sqlalchemy.pool" logger. Defaults to a hexstring of the object's
id.
:param echo: If True, connections being pulled and retrieved
from the pool will be logged to the standard output, as well
as pool sizing information. Echoing can also be achieved by
enabling logging for the "sqlalchemy.pool"
namespace. Defaults to False.
:param use_threadlocal: If set to True, repeated calls to
:meth:`connect` within the same application thread will be
guaranteed to return the same connection object, if one has
already been retrieved from the pool and has not been
returned yet. Offers a slight performance advantage at the
cost of individual transactions by default. The
:meth:`unique_connection` method is provided to bypass the
threadlocal behavior installed into :meth:`connect`.
:param reset_on_return: If true, reset the database state of
connections returned to the pool. This is typically a
ROLLBACK to release locks and transaction resources.
Disable at your own peril. Defaults to True.
:param events: a list of 2-tuples, each of the form
``(callable, target)`` which will be passed to event.listen()
upon construction. Provided here so that event listeners
can be assigned via ``create_engine`` before dialect-level
listeners are applied.
:param listeners: Deprecated. A list of
:class:`~sqlalchemy.interfaces.PoolListener`-like objects or
dictionaries of callables that receive events when DB-API
connections are created, checked out and checked in to the
pool. This has been superseded by
:func:`~sqlalchemy.event.listen`.
"""
if logging_name:
self.logging_name = self._orig_logging_name = logging_name
else:
self._orig_logging_name = None
log.instance_logger(self, echoflag=echo)
self._threadconns = threading.local()
self._creator = creator
self._recycle = recycle
self._use_threadlocal = use_threadlocal
if reset_on_return in ('rollback', True, reset_rollback):
self._reset_on_return = reset_rollback
elif reset_on_return in (None, False, reset_none):
self._reset_on_return = reset_none
elif reset_on_return in ('commit', reset_commit):
self._reset_on_return = reset_commit
else:
raise exc.ArgumentError(
"Invalid value for 'reset_on_return': %r"
% reset_on_return)
self.echo = echo
if _dispatch:
self.dispatch._update(_dispatch, only_propagate=False)
if events:
for fn, target in events:
event.listen(self, target, fn)
if listeners:
util.warn_deprecated(
"The 'listeners' argument to Pool (and "
"create_engine()) is deprecated. Use event.listen().")
for l in listeners:
self.add_listener(l)
示例13: __init__
def __init__(self, *args, **kwargs):
warn_deprecated("SessionContextExt is deprecated. Use ScopedSession(enhance_classes=True)")
super(SessionContextExt, self).__init__(*args, **kwargs)
示例14: warn_deprecated
# backwards compat with the old name
from sqlalchemy.util import warn_deprecated
warn_deprecated(
"The SQLAlchemy PostgreSQL dialect has been renamed from 'postgres' to 'postgresql'. "
"The new URL format is postgresql[+driver]://<user>:<pass>@<host>/<dbname>"
)
from sqlalchemy.dialects.postgresql import *
from sqlalchemy.dialects.postgresql import base
示例15: Copyright
# orm/shard.py
# Copyright (C) 2005-2011 the SQLAlchemy authors and contributors <see AUTHORS file>
#
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
from sqlalchemy import util
util.warn_deprecated(
"Horizontal sharding is now importable via "
"'import sqlalchemy.ext.horizontal_shard"
)
from sqlalchemy.ext.horizontal_shard import *