def has_database(self, db_name):
"""
Check if the database 'db_name' exists on the current connection.
Parameters
----------
db_name : str
The name of the database
Returns
-------
b : bool
True if the database exists, or False otherwise.
"""
if self.db_type == SQL_MYSQL:
with self.engine.connect() as connection:
results = connection.execute("SHOW DATABASES")
try:
for x in results:
if x[0] == db_name.split()[0]:
return db_name
except pymysql.ProgrammingError as ex:
warnings.warn(ex)
raise ex
return False
elif self.db_type == SQL_SQLITE:
return os.path.exists(SqlDB.sqlite_path(db_name))
评论列表
文章目录