NoSuchTableError
is a class within the sqlalchemy.exc
module of the SQLAlchemy project.
ArgumentError,
DataError,
DatabaseError,
IntegrityError,
InvalidRequestError,
NoInspectionAvailable,
OperationalError,
ProgrammingError,
and UnsupportedCompilationError
are several other callables with code examples from the same sqlalchemy.exc
package.
PyHive (PyPI package information) is a set of DB-API and SQLAlchemy interfaces that make it easier to use Presto and Apache Hive with Python. Dropbox's engineering team created this code library, open sourced it and put it out under the Apache 2.0 license.
PyHive / pyhive / tests / sqlalchemy_test_case.py
# sqlalchemy_test_case.py
from __future__ import absolute_import
from __future__ import unicode_literals
import abc
import contextlib
import functools
import pytest
import sqlalchemy
from builtins import object
from future.utils import with_metaclass
from sqlalchemy.exc import NoSuchTableError
from sqlalchemy.schema import Index
from sqlalchemy.schema import MetaData
from sqlalchemy.schema import Table
from sqlalchemy.sql import expression
def with_engine_connection(fn):
@functools.wraps(fn)
def wrapped_fn(self, *args, **kwargs):
engine = self.create_engine()
try:
with contextlib.closing(engine.connect()) as connection:
fn(self, engine, connection, *args, **kwargs)
finally:
engine.dispose()
return wrapped_fn
class SqlAlchemyTestCase(with_metaclass(abc.ABCMeta, object)):
@with_engine_connection
def test_basic_query(self, engine, connection):
rows = connection.execute('SELECT * FROM one_row').fetchall()
self.assertEqual(len(rows), 1)
self.assertEqual(rows[0].number_of_rows, 1) # number_of_rows is the column name
## ... source file continues with no further NoSuchTableError examples...