Here are the examples of the python api sqlalchemy.inspect.get_table_names taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
4 Examples
3
View Complete Implementation : _schemas.py
Copyright MIT License
Author : airbnb
Copyright MIT License
Author : airbnb
@property
def all(self):
"""list<str>: The table names in this database schema."""
if self._table_names is None:
self._table_names = sqlalchemy.inspect(self._metadata.bind).get_table_names(self._schema)
return self._table_names
3
View Complete Implementation : test_reflection.py
Copyright MIT License
Author : analyzeDFIR
Copyright MIT License
Author : analyzeDFIR
def test_get_table_names(self):
tablenames = [
t for t in inspect(testing.db).get_table_names()
if t.lower() in ("t1", "t2")]
eq_(tablenames[0].upper(), tablenames[0].lower())
eq_(tablenames[1].upper(), tablenames[1].lower())
3
View Complete Implementation : sqlalchemy_store.py
Copyright Apache License 2.0
Author : mlflow
Copyright Apache License 2.0
Author : mlflow
@staticmethod
def _verify_registry_tables_exist(engine):
# Verify that all tables have been created.
inspected_tables = set(sqlalchemy.inspect(engine).get_table_names())
expected_tables = [
SqlRegisteredModel.__tablename__,
SqlModelVersion.__tablename__,
]
if any([table not in inspected_tables for table in expected_tables]):
# TODO: Replace the MlflowException with the following line once it's possible to run
# the registry against a different DB than the tracking server:
# mlflow.store.db.utils._initialize_tables(self.engine)
raise MlflowException("Database migration in unexpected state. Run manual upgrade.")
0
View Complete Implementation : sqlalchemy_store.py
Copyright Apache License 2.0
Author : mlflow
Copyright Apache License 2.0
Author : mlflow
def __init__(self, db_uri, default_artifact_root):
"""
Create a database backed store.
:param db_uri: The SQLAlchemy database URI string to connect to the database. See
the `SQLAlchemy docs
<https://docs.sqlalchemy.org/en/latest/core/engines.html#database-urls>`_
for format specifications. Mlflow supports the dialects ``mysql``,
``mssql``, ``sqlite``, and ``postgresql``.
:param default_artifact_root: Path/URI to location suitable for large data (such as a blob
store object, DBFS path, or shared NFS file system).
"""
super(SqlAlchemyStore, self).__init__()
self.db_uri = db_uri
self.db_type = extract_db_type_from_uri(db_uri)
self.artifact_root_uri = default_artifact_root
self.engine = mlflow.store.db.utils.create_sqlalchemy_engine(db_uri)
# On a completely fresh MLflow installation against an empty database (verify database
# emptiness by checking that 'experiments' etc aren't in the list of table names), run all
# DB migrations
expected_tables = [
SqlExperiment.__tablename__,
SqlRun.__tablename__,
SqlMetric.__tablename__,
SqlParam.__tablename__,
SqlTag.__tablename__,
SqlExperimentTag.__tablename__,
SqlLatestMetric.__tablename__,
]
inspected_tables = set(sqlalchemy.inspect(self.engine).get_table_names())
if any([table not in inspected_tables for table in expected_tables]):
mlflow.store.db.utils._initialize_tables(self.engine)
Base.metadata.bind = self.engine
SessionMaker = sqlalchemy.orm.sessionmaker(bind=self.engine)
self.ManagedSessionMaker = mlflow.store.db.utils._get_managed_session_maker(SessionMaker)
mlflow.store.db.utils._verify_schema(self.engine)
if is_local_uri(default_artifact_root):
mkdir(local_file_uri_to_path(default_artifact_root))
if len(self.list_experiments()) == 0:
with self.ManagedSessionMaker() as session:
self._create_default_experiment(session)