查看所有数据库
from mysql.db_object import Database
db = Database(
host="localhost",
port=3306,
database="",
username="root",
password="zhangdapeng520"
)
print(db.get_all_database())
删除数据库
from mysql.db_object import Database
db = Database(
host="localhost",
port=3306,
database="",
username="root",
password="zhangdapeng520"
)
print(db.get_all_database())
db.delete_database("gx")
print(db.get_all_database())
添加数据库
from mysql.db_object import Database
db = Database(
host="localhost",
port=3306,
database="",
username="root",
password="zhangdapeng520"
)
db.delete_database("gx")
print(db.get_all_database())
db.add_database("gx")
print(db.get_all_database())
重建数据库
from mysql.db_object import Database
db = Database(
host="localhost",
port=3306,
database="",
username="root",
password="zhangdapeng520"
)
db.add_database_force("gx")
print(db.get_all_database())
判断数据库是否存在
from mysql.db_object import Database
db = Database(
host="localhost",
port=3306,
database="",
username="root",
password="zhangdapeng520"
)
db.add_database_force("gx")
print("gx" in db.get_all_database())