desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Populate from the listeners in another :class:`_Dispatch`
object.'
| def _update(self, other, only_propagate=True):
| for ls in _event_descriptors(other):
if isinstance(ls, _EmptyListener):
continue
getattr(self, ls.name).for_modify(self)._update(ls, only_propagate=only_propagate)
|
'Return True if this event key is registered to listen.'
| def contains(self):
| return (self._key in _key_to_collection)
|
'Clear all class level listeners'
| def clear(self):
| to_clear = set()
for dispatcher in self._clslevel.values():
to_clear.update(dispatcher)
dispatcher[:] = []
registry._clear(self, to_clear)
|
'Return an event collection which can be modified.
For _DispatchDescriptor at the class level of
a dispatcher, this returns self.'
| def for_modify(self, obj):
| return self
|
'Return an event collection which can be modified.
For _EmptyListener at the instance level of
a dispatcher, this generates a new
_ListenerCollection, applies it to the instance,
and returns it.'
| def for_modify(self, obj):
| result = _ListenerCollection(self.parent, obj._parent_cls)
if (obj.__dict__[self.name] is self):
obj.__dict__[self.name] = result
return result
|
'Execute this event.'
| def __call__(self, *args, **kw):
| for fn in self.parent_listeners:
fn(*args, **kw)
|
'Execute this event, but only if it has not been
executed already for this collection.'
| def exec_once(self, *args, **kw):
| if (not self._exec_once):
with self._exec_once_mutex:
if (not self._exec_once):
try:
self(*args, **kw)
finally:
self._exec_once = True
|
'Execute this event.'
| def __call__(self, *args, **kw):
| for fn in self.parent_listeners:
fn(*args, **kw)
for fn in self.listeners:
fn(*args, **kw)
|
'Return an event collection which can be modified.
For _ListenerCollection at the instance level of
a dispatcher, this returns self.'
| def for_modify(self, obj):
| return self
|
'Populate from the listeners in another :class:`_Dispatch`
object.'
| def _update(self, other, only_propagate=True):
| existing_listeners = self.listeners
existing_listener_set = set(existing_listeners)
self.propagate.update(other.propagate)
other_listeners = [l for l in other.listeners if (((l not in existing_listener_set) and (not only_propagate)) or (l in self.propagate))]
existing_listeners.extend(other_listener... |
'Construct a new Connection.
The constructor here is not public and is only called only by an
:class:`.Engine`. See :meth:`.Engine.connect` and
:meth:`.Engine.contextual_connect` methods.'
| def __init__(self, engine, connection=None, close_with_result=False, _branch=False, _execution_options=None, _dispatch=None, _has_events=None):
| self.engine = engine
self.dialect = engine.dialect
self.__connection = (connection or engine.raw_connection())
self.__transaction = None
self.should_close_with_result = close_with_result
self.__savepoint_seq = 0
self.__branch = _branch
self.__invalid = False
self.__can_reconnect = Tr... |
'Return a new Connection which references this Connection\'s
engine and connection; but does not have close_with_result enabled,
and also whose close() method does nothing.
This is used to execute "sub" statements within a single execution,
usually an INSERT statement.'
| def _branch(self):
| return self.engine._connection_cls(self.engine, self.__connection, _branch=True, _has_events=self._has_events, _dispatch=self.dispatch)
|
'Create a shallow copy of this Connection.'
| def _clone(self):
| c = self.__class__.__new__(self.__class__)
c.__dict__ = self.__dict__.copy()
return c
|
'Set non-SQL options for the connection which take effect
during execution.
The method returns a copy of this :class:`.Connection` which references
the same underlying DBAPI connection, but also defines the given
execution options which will take effect for a call to
:meth:`execute`. As the new :class:`.Connection` ref... | def execution_options(self, **opt):
| c = self._clone()
c._execution_options = c._execution_options.union(opt)
if (self._has_events or self.engine._has_events):
self.dispatch.set_connection_execution_options(c, opt)
self.dialect.set_connection_execution_options(c, opt)
return c
|
'Return True if this connection is closed.'
| @property
def closed(self):
| return (('_Connection__connection' not in self.__dict__) and (not self.__can_reconnect))
|
'Return True if this connection was invalidated.'
| @property
def invalidated(self):
| return self.__invalid
|
'The underlying DB-API connection managed by this Connection.'
| @property
def connection(self):
| try:
return self.__connection
except AttributeError:
return self._revalidate_connection()
|
'Info dictionary associated with the underlying DBAPI connection
referred to by this :class:`.Connection`, allowing user-defined
data to be associated with the connection.
The data here will follow along with the DBAPI connection including
after it is returned to the connection pool and used again
in subsequent instanc... | @property
def info(self):
| return self.connection.info
|
'Returns a branched version of this :class:`.Connection`.
The :meth:`.Connection.close` method on the returned
:class:`.Connection` can be called and this
:class:`.Connection` will remain open.
This method provides usage symmetry with
:meth:`.Engine.connect`, including for usage
with context managers.'
| def connect(self):
| return self._branch()
|
'Returns a branched version of this :class:`.Connection`.
The :meth:`.Connection.close` method on the returned
:class:`.Connection` can be called and this
:class:`.Connection` will remain open.
This method provides usage symmetry with
:meth:`.Engine.contextual_connect`, including for usage
with context managers.'
| def contextual_connect(self, **kwargs):
| return self._branch()
|
'Invalidate the underlying DBAPI connection associated with
this :class:`.Connection`.
The underlying DBAPI connection is literally closed (if
possible), and is discarded. Its source connection pool will
typically lazily create a new connection to replace it.
Upon the next use (where "use" typically means using the
:m... | def invalidate(self, exception=None):
| if self.invalidated:
return
if self.closed:
raise exc.ResourceClosedError('This Connection is closed')
if self._connection_is_valid:
self.__connection.invalidate(exception)
del self.__connection
self.__invalid = True
|
'Detach the underlying DB-API connection from its connection pool.
E.g.::
with engine.connect() as conn:
conn.detach()
conn.execute("SET search_path TO schema1, schema2")
# work with connection
# connection is fully closed (since we used "with:", can
# also call .close())
This :class:`.Connection` instance will remain ... | def detach(self):
| self.__connection.detach()
|
'Begin a transaction and return a transaction handle.
The returned object is an instance of :class:`.Transaction`.
This object represents the "scope" of the transaction,
which completes when either the :meth:`.Transaction.rollback`
or :meth:`.Transaction.commit` method is called.
Nested calls to :meth:`.begin` on the s... | def begin(self):
| if (self.__transaction is None):
self.__transaction = RootTransaction(self)
return self.__transaction
else:
return Transaction(self, self.__transaction)
|
'Begin a nested transaction and return a transaction handle.
The returned object is an instance of :class:`.NestedTransaction`.
Nested transactions require SAVEPOINT support in the
underlying database. Any transaction in the hierarchy may
``commit`` and ``rollback``, however the outermost transaction
still controls th... | def begin_nested(self):
| if (self.__transaction is None):
self.__transaction = RootTransaction(self)
else:
self.__transaction = NestedTransaction(self, self.__transaction)
return self.__transaction
|
'Begin a two-phase or XA transaction and return a transaction
handle.
The returned object is an instance of :class:`.TwoPhaseTransaction`,
which in addition to the methods provided by
:class:`.Transaction`, also provides a
:meth:`~.TwoPhaseTransaction.prepare` method.
:param xid: the two phase transaction id. If not s... | def begin_twophase(self, xid=None):
| if (self.__transaction is not None):
raise exc.InvalidRequestError('Cannot start a two phase transaction when a transaction is already in progress.')
if (xid is None):
xid = self.engine.dialect.create_xid()
self.__transaction = TwoPhaseTransaction(self, xi... |
'Return True if a transaction is in progress.'
| def in_transaction(self):
| return (self.__transaction is not None)
|
'Close this :class:`.Connection`.
This results in a release of the underlying database
resources, that is, the DBAPI connection referenced
internally. The DBAPI connection is typically restored
back to the connection-holding :class:`.Pool` referenced
by the :class:`.Engine` that produced this
:class:`.Connection`. Any ... | def close(self):
| try:
conn = self.__connection
except AttributeError:
pass
else:
if (not self.__branch):
conn.close()
if (conn._reset_agent is self.__transaction):
conn._reset_agent = None
del self.__connection
self.__can_reconnect = False
self.__transa... |
'Executes and returns the first column of the first row.
The underlying result/cursor is closed after execution.'
| def scalar(self, object, *multiparams, **params):
| return self.execute(object, *multiparams, **params).scalar()
|
'Executes the a SQL statement construct and returns a
:class:`.ResultProxy`.
:param object: The statement to be executed. May be
one of:
* a plain string
* any :class:`.ClauseElement` construct that is also
a subclass of :class:`.Executable`, such as a
:func:`~.expression.select` construct
* a :class:`.FunctionElement... | def execute(self, object, *multiparams, **params):
| if isinstance(object, util.string_types[0]):
return self._execute_text(object, multiparams, params)
try:
meth = object._execute_on_connection
except AttributeError:
raise exc.InvalidRequestError(('Unexecutable object type: %s' % type(object)))
else:
return meth(s... |
'Execute a sql.FunctionElement object.'
| def _execute_function(self, func, multiparams, params):
| return self._execute_clauseelement(func.select(), multiparams, params)
|
'Execute a schema.ColumnDefault object.'
| def _execute_default(self, default, multiparams, params):
| if (self._has_events or self.engine._has_events):
for fn in self.dispatch.before_execute:
(default, multiparams, params) = fn(self, default, multiparams, params)
try:
try:
conn = self.__connection
except AttributeError:
conn = self._revalidate_connecti... |
'Execute a schema.DDL object.'
| def _execute_ddl(self, ddl, multiparams, params):
| if (self._has_events or self.engine._has_events):
for fn in self.dispatch.before_execute:
(ddl, multiparams, params) = fn(self, ddl, multiparams, params)
dialect = self.dialect
compiled = ddl.compile(dialect=dialect)
ret = self._execute_context(dialect, dialect.execution_ctx_cls._ini... |
'Execute a sql.ClauseElement object.'
| def _execute_clauseelement(self, elem, multiparams, params):
| if (self._has_events or self.engine._has_events):
for fn in self.dispatch.before_execute:
(elem, multiparams, params) = fn(self, elem, multiparams, params)
distilled_params = _distill_params(multiparams, params)
if distilled_params:
keys = distilled_params[0].keys()
else:
... |
'Execute a sql.Compiled object.'
| def _execute_compiled(self, compiled, multiparams, params):
| if (self._has_events or self.engine._has_events):
for fn in self.dispatch.before_execute:
(compiled, multiparams, params) = fn(self, compiled, multiparams, params)
dialect = self.dialect
parameters = _distill_params(multiparams, params)
ret = self._execute_context(dialect, dialect.ex... |
'Execute a string SQL statement.'
| def _execute_text(self, statement, multiparams, params):
| if (self._has_events or self.engine._has_events):
for fn in self.dispatch.before_execute:
(statement, multiparams, params) = fn(self, statement, multiparams, params)
dialect = self.dialect
parameters = _distill_params(multiparams, params)
ret = self._execute_context(dialect, dialect.... |
'Create an :class:`.ExecutionContext` and execute, returning
a :class:`.ResultProxy`.'
| def _execute_context(self, dialect, constructor, statement, parameters, *args):
| try:
try:
conn = self.__connection
except AttributeError:
conn = self._revalidate_connection()
context = constructor(dialect, self, conn, *args)
except Exception as e:
self._handle_dbapi_exception(e, util.text_type(statement), parameters, None, None)
i... |
'Execute a statement + params on the given cursor.
Adds appropriate logging and exception handling.
This method is used by DefaultDialect for special-case
executions, such as for sequences and column defaults.
The path of statement execution in the majority of cases
terminates at _execute_context().'
| def _cursor_execute(self, cursor, statement, parameters, context=None):
| if (self._has_events or self.engine._has_events):
for fn in self.dispatch.before_cursor_execute:
(statement, parameters) = fn(self, cursor, statement, parameters, context, False)
if self._echo:
self.engine.logger.info(statement)
self.engine.logger.info('%r', parameters)
t... |
'Close the given cursor, catching exceptions
and turning into log warnings.'
| def _safe_close_cursor(self, cursor):
| try:
cursor.close()
except (SystemExit, KeyboardInterrupt):
raise
except Exception:
self.connection._logger.error('Error closing cursor', exc_info=True)
|
'Execute the given function within a transaction boundary.
The function is passed this :class:`.Connection`
as the first argument, followed by the given \*args and \**kwargs,
e.g.::
def do_something(conn, x, y):
conn.execute("some statement", {\'x\':x, \'y\':y})
conn.transaction(do_something, 5, 10)
The operations insi... | def transaction(self, callable_, *args, **kwargs):
| trans = self.begin()
try:
ret = self.run_callable(callable_, *args, **kwargs)
trans.commit()
return ret
except:
with util.safe_reraise():
trans.rollback()
|
'Given a callable object or function, execute it, passing
a :class:`.Connection` as the first argument.
The given \*args and \**kwargs are passed subsequent
to the :class:`.Connection` argument.
This function, along with :meth:`.Engine.run_callable`,
allows a function to be run with a :class:`.Connection`
or :class:`.E... | def run_callable(self, callable_, *args, **kwargs):
| return callable_(self, *args, **kwargs)
|
'Close this :class:`.Transaction`.
If this transaction is the base transaction in a begin/commit
nesting, the transaction will rollback(). Otherwise, the
method returns.
This is used to cancel a Transaction without affecting the scope of
an enclosing transaction.'
| def close(self):
| if (not self._parent.is_active):
return
if (self._parent is self):
self.rollback()
|
'Roll back this :class:`.Transaction`.'
| def rollback(self):
| if (not self._parent.is_active):
return
self._do_rollback()
self.is_active = False
|
'Commit this :class:`.Transaction`.'
| def commit(self):
| if (not self._parent.is_active):
raise exc.InvalidRequestError('This transaction is inactive')
self._do_commit()
self.is_active = False
|
'Prepare this :class:`.TwoPhaseTransaction`.
After a PREPARE, the transaction can be committed.'
| def prepare(self):
| if (not self._parent.is_active):
raise exc.InvalidRequestError('This transaction is inactive')
self.connection._prepare_twophase_impl(self.xid)
self._is_prepared = True
|
'Update the default execution_options dictionary
of this :class:`.Engine`.
The given keys/values in \**opt are added to the
default execution options that will be used for
all connections. The initial contents of this dictionary
can be sent via the ``execution_options`` parameter
to :func:`.create_engine`.
.. seealso:... | def update_execution_options(self, **opt):
| self._execution_options = self._execution_options.union(opt)
self.dispatch.set_engine_execution_options(self, opt)
self.dialect.set_engine_execution_options(self, opt)
|
'Return a new :class:`.Engine` that will provide
:class:`.Connection` objects with the given execution options.
The returned :class:`.Engine` remains related to the original
:class:`.Engine` in that it shares the same connection pool and
other state:
* The :class:`.Pool` used by the new :class:`.Engine` is the
same ins... | def execution_options(self, **opt):
| return OptionEngine(self, opt)
|
'String name of the :class:`~sqlalchemy.engine.interfaces.Dialect`
in use by this :class:`Engine`.'
| @property
def name(self):
| return self.dialect.name
|
'Driver name of the :class:`~sqlalchemy.engine.interfaces.Dialect`
in use by this :class:`Engine`.'
| @property
def driver(self):
| return self.dialect.driver
|
'Dispose of the connection pool used by this :class:`.Engine`.
A new connection pool is created immediately after the old one has
been disposed. This new pool, like all SQLAlchemy connection pools,
does not make any actual connections to the database until one is
first requested.
This method has two general use cases... | def dispose(self):
| self.pool.dispose()
self.pool = self.pool.recreate()
|
'Return a context manager delivering a :class:`.Connection`
with a :class:`.Transaction` established.
E.g.::
with engine.begin() as conn:
conn.execute("insert into table (x, y, z) values (1, 2, 3)")
conn.execute("my_special_procedure(5)")
Upon successful operation, the :class:`.Transaction`
is committed. If an error i... | def begin(self, close_with_result=False):
| conn = self.contextual_connect(close_with_result=close_with_result)
try:
trans = conn.begin()
except:
with util.safe_reraise():
conn.close()
return Engine._trans_ctx(conn, trans, close_with_result)
|
'Execute the given function within a transaction boundary.
The function is passed a :class:`.Connection` newly procured
from :meth:`.Engine.contextual_connect` as the first argument,
followed by the given \*args and \**kwargs.
e.g.::
def do_something(conn, x, y):
conn.execute("some statement", {\'x\':x, \'y\':y})
engin... | def transaction(self, callable_, *args, **kwargs):
| with self.contextual_connect() as conn:
return conn.transaction(callable_, *args, **kwargs)
|
'Given a callable object or function, execute it, passing
a :class:`.Connection` as the first argument.
The given \*args and \**kwargs are passed subsequent
to the :class:`.Connection` argument.
This function, along with :meth:`.Connection.run_callable`,
allows a function to be run with a :class:`.Connection`
or :class... | def run_callable(self, callable_, *args, **kwargs):
| with self.contextual_connect() as conn:
return conn.run_callable(callable_, *args, **kwargs)
|
'Executes the given construct and returns a :class:`.ResultProxy`.
The arguments are the same as those used by
:meth:`.Connection.execute`.
Here, a :class:`.Connection` is acquired using the
:meth:`~.Engine.contextual_connect` method, and the statement executed
with that connection. The returned :class:`.ResultProxy` i... | def execute(self, statement, *multiparams, **params):
| connection = self.contextual_connect(close_with_result=True)
return connection.execute(statement, *multiparams, **params)
|
'Return a new :class:`.Connection` object.
The :class:`.Connection` object is a facade that uses a DBAPI
connection internally in order to communicate with the database. This
connection is procured from the connection-holding :class:`.Pool`
referenced by this :class:`.Engine`. When the
:meth:`~.Connection.close` metho... | def connect(self, **kwargs):
| return self._connection_cls(self, **kwargs)
|
'Return a :class:`.Connection` object which may be part of some
ongoing context.
By default, this method does the same thing as :meth:`.Engine.connect`.
Subclasses of :class:`.Engine` may override this method
to provide contextual behavior.
:param close_with_result: When True, the first :class:`.ResultProxy`
created by... | def contextual_connect(self, close_with_result=False, **kwargs):
| return self._connection_cls(self, self.pool.connect(), close_with_result=close_with_result, **kwargs)
|
'Return a list of all table names available in the database.
:param schema: Optional, retrieve names from a non-default schema.
:param connection: Optional, use a specified connection. Default is
the ``contextual_connect`` for this ``Engine``.'
| def table_names(self, schema=None, connection=None):
| with self._optional_conn_ctx_manager(connection) as conn:
if (not schema):
schema = self.dialect.default_schema_name
return self.dialect.get_table_names(conn, schema)
|
'Return True if the given backend has a table of the given name.
.. seealso::
:ref:`metadata_reflection_inspector` - detailed schema inspection using
the :class:`.Inspector` interface.
:class:`.quoted_name` - used to pass quoting information along
with a schema identifier.'
| def has_table(self, table_name, schema=None):
| return self.run_callable(self.dialect.has_table, table_name, schema)
|
'Return a "raw" DBAPI connection from the connection pool.
The returned object is a proxied version of the DBAPI
connection object used by the underlying driver in use.
The object will have all the same behavior as the real DBAPI
connection, except that its ``close()`` method will result in the
connection being returne... | def raw_connection(self):
| return self.pool.unique_connection()
|
'Return True if this RowProxy contains the given key.'
| def has_key(self, key):
| return self._parent._has_key(self._row, key)
|
'Return a list of tuples, each tuple containing a key/value pair.'
| def items(self):
| return [(key, self[key]) for key in self.keys()]
|
'Return the list of keys as strings represented by this RowProxy.'
| def keys(self):
| return self._parent.keys
|
'Set a synonym for the given name.
Some dialects (SQLite at the moment) may use this to
adjust the column names that are significant within a
row.'
| @util.pending_deprecation('0.8', 'sqlite dialect uses _translate_colname() now')
def _set_keymap_synonym(self, name, origname):
| rec = (processor, obj, i) = self._keymap[(origname if self.case_sensitive else origname.lower())]
if (self._keymap.setdefault(name, rec) is not rec):
self._keymap[name] = (processor, obj, None)
|
'Return the current set of string keys for rows.'
| def keys(self):
| if self._metadata:
return self._metadata.keys
else:
return []
|
'Return the \'rowcount\' for this result.
The \'rowcount\' reports the number of rows *matched*
by the WHERE criterion of an UPDATE or DELETE statement.
.. note::
Notes regarding :attr:`.ResultProxy.rowcount`:
* This attribute returns the number of rows *matched*,
which is not necessarily the same as the number of rows... | @util.memoized_property
def rowcount(self):
| try:
return self.context.rowcount
except Exception as e:
self.connection._handle_dbapi_exception(e, None, None, self.cursor, self.context)
|
'return the \'lastrowid\' accessor on the DBAPI cursor.
This is a DBAPI specific method and is only functional
for those backends which support it, for statements
where it is appropriate. It\'s behavior is not
consistent across backends.
Usage of this method is normally unnecessary when
using insert() expression const... | @property
def lastrowid(self):
| try:
return self._saved_cursor.lastrowid
except Exception as e:
self.connection._handle_dbapi_exception(e, None, None, self._saved_cursor, self.context)
|
'True if this :class:`.ResultProxy` returns rows.
I.e. if it is legal to call the methods
:meth:`~.ResultProxy.fetchone`,
:meth:`~.ResultProxy.fetchmany`
:meth:`~.ResultProxy.fetchall`.'
| @property
def returns_rows(self):
| return (self._metadata is not None)
|
'True if this :class:`.ResultProxy` is the result
of a executing an expression language compiled
:func:`.expression.insert` construct.
When True, this implies that the
:attr:`inserted_primary_key` attribute is accessible,
assuming the statement did not include
a user defined "returning" construct.'
| @property
def is_insert(self):
| return self.context.isinsert
|
'May be overridden by subclasses.'
| def _cursor_description(self):
| return self._saved_cursor.description
|
'Close this ResultProxy.
Closes the underlying DBAPI cursor corresponding to the execution.
Note that any data cached within this ResultProxy is still available.
For some types of results, this may include buffered rows.
If this ResultProxy was generated from an implicit execution,
the underlying Connection will also b... | def close(self, _autoclose_connection=True):
| if (not self.closed):
self.closed = True
self.connection._safe_close_cursor(self.cursor)
if (_autoclose_connection and self.connection.should_close_with_result):
self.connection.close()
self.cursor = None
|
'Return the primary key for the row just inserted.
The return value is a list of scalar values
corresponding to the list of primary key columns
in the target table.
This only applies to single row :func:`.insert`
constructs which did not explicitly specify
:meth:`.Insert.returning`.
Note that primary key columns which ... | @util.memoized_property
def inserted_primary_key(self):
| if (not self.context.compiled):
raise exc.InvalidRequestError('Statement is not a compiled expression construct.')
elif (not self.context.isinsert):
raise exc.InvalidRequestError('Statement is not an insert() expression construct.')
elif self.context._is_e... |
'Return the collection of updated parameters from this
execution.
Raises :class:`~sqlalchemy.exc.InvalidRequestError` if the executed
statement is not a compiled expression construct
or is not an update() construct.'
| def last_updated_params(self):
| if (not self.context.compiled):
raise exc.InvalidRequestError('Statement is not a compiled expression construct.')
elif (not self.context.isupdate):
raise exc.InvalidRequestError('Statement is not an update() expression construct.')
elif self.context.execu... |
'Return the collection of inserted parameters from this
execution.
Raises :class:`~sqlalchemy.exc.InvalidRequestError` if the executed
statement is not a compiled expression construct
or is not an insert() construct.'
| def last_inserted_params(self):
| if (not self.context.compiled):
raise exc.InvalidRequestError('Statement is not a compiled expression construct.')
elif (not self.context.isinsert):
raise exc.InvalidRequestError('Statement is not an insert() expression construct.')
elif self.context.execu... |
'Return the values of default columns that were fetched using
the :meth:`.ValuesBase.return_defaults` feature.
The value is an instance of :class:`.RowProxy`, or ``None``
if :meth:`.ValuesBase.return_defaults` was not used or if the
backend does not support RETURNING.
.. versionadded:: 0.9.0
.. seealso::
:meth:`.Values... | @property
def returned_defaults(self):
| return self.context.returned_defaults
|
'Return ``lastrow_has_defaults()`` from the underlying
:class:`.ExecutionContext`.
See :class:`.ExecutionContext` for details.'
| def lastrow_has_defaults(self):
| return self.context.lastrow_has_defaults()
|
'Return ``postfetch_cols()`` from the underlying
:class:`.ExecutionContext`.
See :class:`.ExecutionContext` for details.
Raises :class:`~sqlalchemy.exc.InvalidRequestError` if the executed
statement is not a compiled expression construct
or is not an insert() or update() construct.'
| def postfetch_cols(self):
| if (not self.context.compiled):
raise exc.InvalidRequestError('Statement is not a compiled expression construct.')
elif ((not self.context.isinsert) and (not self.context.isupdate)):
raise exc.InvalidRequestError('Statement is not an insert() or update() ex... |
'Return ``prefetch_cols()`` from the underlying
:class:`.ExecutionContext`.
See :class:`.ExecutionContext` for details.
Raises :class:`~sqlalchemy.exc.InvalidRequestError` if the executed
statement is not a compiled expression construct
or is not an insert() or update() construct.'
| def prefetch_cols(self):
| if (not self.context.compiled):
raise exc.InvalidRequestError('Statement is not a compiled expression construct.')
elif ((not self.context.isinsert) and (not self.context.isupdate)):
raise exc.InvalidRequestError('Statement is not an insert() or update() ex... |
'Return ``supports_sane_rowcount`` from the dialect.
See :attr:`.ResultProxy.rowcount` for background.'
| def supports_sane_rowcount(self):
| return self.dialect.supports_sane_rowcount
|
'Return ``supports_sane_multi_rowcount`` from the dialect.
See :attr:`.ResultProxy.rowcount` for background.'
| def supports_sane_multi_rowcount(self):
| return self.dialect.supports_sane_multi_rowcount
|
'Fetch all rows, just like DB-API ``cursor.fetchall()``.'
| def fetchall(self):
| try:
l = self.process_rows(self._fetchall_impl())
self.close()
return l
except Exception as e:
self.connection._handle_dbapi_exception(e, None, None, self.cursor, self.context)
|
'Fetch many rows, just like DB-API
``cursor.fetchmany(size=cursor.arraysize)``.
If rows are present, the cursor remains open after this is called.
Else the cursor is automatically closed and an empty list is returned.'
| def fetchmany(self, size=None):
| try:
l = self.process_rows(self._fetchmany_impl(size))
if (len(l) == 0):
self.close()
return l
except Exception as e:
self.connection._handle_dbapi_exception(e, None, None, self.cursor, self.context)
|
'Fetch one row, just like DB-API ``cursor.fetchone()``.
If a row is present, the cursor remains open after this is called.
Else the cursor is automatically closed and None is returned.'
| def fetchone(self):
| try:
row = self._fetchone_impl()
if (row is not None):
return self.process_rows([row])[0]
else:
self.close()
return None
except Exception as e:
self.connection._handle_dbapi_exception(e, None, None, self.cursor, self.context)
|
'Fetch the first row and then close the result set unconditionally.
Returns None if no row is present.'
| def first(self):
| if (self._metadata is None):
self._non_result()
try:
row = self._fetchone_impl()
except Exception as e:
self.connection._handle_dbapi_exception(e, None, None, self.cursor, self.context)
try:
if (row is not None):
return self.process_rows([row])[0]
else... |
'Fetch the first column of the first row, and close the result set.
Returns None if no row is present.'
| def scalar(self):
| row = self.first()
if (row is not None):
return row[0]
else:
return None
|
'Build DB-API compatible connection arguments.
Given a :class:`~sqlalchemy.engine.url.URL` object, returns a tuple
consisting of a `*args`/`**kwargs` suitable to send directly
to the dbapi\'s connect function.'
| def create_connect_args(self, url):
| raise NotImplementedError()
|
'Transform a generic type to a dialect-specific type.
Dialect classes will usually use the
:func:`.types.adapt_type` function in the types module to
accomplish this.
The returned result is cached *per dialect class* so can
contain no dialect-instance state.'
| @classmethod
def type_descriptor(cls, typeobj):
| raise NotImplementedError()
|
'Called during strategized creation of the dialect with a
connection.
Allows dialects to configure options based on server version info or
other properties.
The connection passed here is a SQLAlchemy Connection object,
with full capabilities.
The initalize() method of the base dialect should be called via
super().'
| def initialize(self, connection):
| pass
|
'Load table description from the database.
Given a :class:`.Connection` and a
:class:`~sqlalchemy.schema.Table` object, reflect its columns and
properties from the database.
The implementation of this method is provided by
:meth:`.DefaultDialect.reflecttable`, which makes use of
:class:`.Inspector` to retrieve column i... | def reflecttable(self, connection, table, include_columns, exclude_columns):
| raise NotImplementedError()
|
'Return information about columns in `table_name`.
Given a :class:`.Connection`, a string
`table_name`, and an optional string `schema`, return column
information as a list of dictionaries with these keys:
name
the column\'s name
type
[sqlalchemy.types#TypeEngine]
nullable
boolean
default
the column\'s default value
au... | def get_columns(self, connection, table_name, schema=None, **kw):
| raise NotImplementedError()
|
'Return information about primary keys in `table_name`.
Deprecated. This method is only called by the default
implementation of :meth:`.Dialect.get_pk_constraint`. Dialects should
instead implement the :meth:`.Dialect.get_pk_constraint` method directly.'
| def get_primary_keys(self, connection, table_name, schema=None, **kw):
| raise NotImplementedError()
|
'Return information about the primary key constraint on
table_name`.
Given a :class:`.Connection`, a string
`table_name`, and an optional string `schema`, return primary
key information as a dictionary with these keys:
constrained_columns
a list of column names that make up the primary key
name
optional name of the pri... | def get_pk_constraint(self, connection, table_name, schema=None, **kw):
| raise NotImplementedError()
|
'Return information about foreign_keys in `table_name`.
Given a :class:`.Connection`, a string
`table_name`, and an optional string `schema`, return foreign
key information as a list of dicts with these keys:
name
the constraint\'s name
constrained_columns
a list of column names that make up the foreign key
referred_sc... | def get_foreign_keys(self, connection, table_name, schema=None, **kw):
| raise NotImplementedError()
|
'Return a list of table names for `schema`.'
| def get_table_names(self, connection, schema=None, **kw):
| raise NotImplementedError
|
'Return a list of all view names available in the database.
schema:
Optional, retrieve names from a non-default schema.'
| def get_view_names(self, connection, schema=None, **kw):
| raise NotImplementedError()
|
'Return view definition.
Given a :class:`.Connection`, a string
`view_name`, and an optional string `schema`, return the view
definition.'
| def get_view_definition(self, connection, view_name, schema=None, **kw):
| raise NotImplementedError()
|
'Return information about indexes in `table_name`.
Given a :class:`.Connection`, a string
`table_name` and an optional string `schema`, return index
information as a list of dictionaries with these keys:
name
the index\'s name
column_names
list of column names in order
unique
boolean'
| def get_indexes(self, connection, table_name, schema=None, **kw):
| raise NotImplementedError()
|
'Return information about unique constraints in `table_name`.
Given a string `table_name` and an optional string `schema`, return
unique constraint information as a list of dicts with these keys:
name
the unique constraint\'s name
column_names
list of column names in order
\**kw
other options passed to the dialect\'s g... | def get_unique_constraints(self, connection, table_name, schema=None, **kw):
| raise NotImplementedError()
|
'convert the given name to lowercase if it is detected as
case insensitive.
this method is only used if the dialect defines
requires_name_normalize=True.'
| def normalize_name(self, name):
| raise NotImplementedError()
|
'convert the given name to a case insensitive identifier
for the backend if it is an all-lowercase name.
this method is only used if the dialect defines
requires_name_normalize=True.'
| def denormalize_name(self, name):
| raise NotImplementedError()
|
'Check the existence of a particular table in the database.
Given a :class:`.Connection` object and a string
`table_name`, return True if the given table (possibly within
the specified `schema`) exists in the database, False
otherwise.'
| def has_table(self, connection, table_name, schema=None):
| raise NotImplementedError()
|
'Check the existence of a particular sequence in the database.
Given a :class:`.Connection` object and a string
`sequence_name`, return True if the given sequence exists in
the database, False otherwise.'
| def has_sequence(self, connection, sequence_name, schema=None):
| raise NotImplementedError()
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.