修补数据库安装脚本未指定端口问题
This commit is contained in:
+7
-4
@@ -1,12 +1,13 @@
|
||||
import sys
|
||||
|
||||
sys.path.append('../')
|
||||
import sqlparse
|
||||
import pymysql
|
||||
from applications.config.database import HOST, USERNAME, PASSWORD, DATABASE,PORT
|
||||
from applications.config.database import HOST, USERNAME, PASSWORD, DATABASE, PORT
|
||||
|
||||
|
||||
def is_exist_database():
|
||||
db = pymysql.connect(host=HOST,port = int(PORT), user=USERNAME, password=PASSWORD, charset='utf8mb4')
|
||||
db = pymysql.connect(host=HOST, port=int(PORT), user=USERNAME, password=PASSWORD, charset='utf8mb4')
|
||||
cursor1 = db.cursor()
|
||||
sql = "select * from information_schema.SCHEMATA WHERE SCHEMA_NAME = '%s' ; " % DATABASE
|
||||
res = cursor1.execute(sql)
|
||||
@@ -15,7 +16,7 @@ def is_exist_database():
|
||||
|
||||
|
||||
def init_database():
|
||||
db = pymysql.connect(host=HOST,port = int(PORT), user=USERNAME, password=PASSWORD, charset='utf8mb4')
|
||||
db = pymysql.connect(host=HOST, port=int(PORT), user=USERNAME, password=PASSWORD, charset='utf8mb4')
|
||||
cursor1 = db.cursor()
|
||||
sql = "CREATE DATABASE IF NOT EXISTS %s" % DATABASE
|
||||
res = cursor1.execute(sql)
|
||||
@@ -24,7 +25,8 @@ def init_database():
|
||||
|
||||
|
||||
def execute_fromfile(filename):
|
||||
db = pymysql.connect(host=HOST, user=USERNAME, password=PASSWORD, database=DATABASE, charset='utf8mb4')
|
||||
db = pymysql.connect(host=HOST, port=int(PORT), user=USERNAME, password=PASSWORD, database=DATABASE,
|
||||
charset='utf8mb4')
|
||||
fd = open(filename, 'r', encoding='utf-8')
|
||||
cursor = db.cursor()
|
||||
sqlfile = fd.read()
|
||||
@@ -53,5 +55,6 @@ def init_db():
|
||||
print('表创建成功')
|
||||
print('欢迎使用pear-admin-flask,请使用 flask run 命令启动程序')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
init_db()
|
||||
|
||||
Reference in New Issue
Block a user