This commit is contained in:
@@ -1,17 +1,22 @@
|
||||
from secret import host, user, password, database
|
||||
from .secret import host, user, password, database
|
||||
|
||||
import pymysql.cursors
|
||||
|
||||
connection = pymysql.connect(
|
||||
host=host,
|
||||
user=user,
|
||||
password=password,
|
||||
database=database,
|
||||
charset='utf8mb4',
|
||||
cursorclass=pymysql.cursors.DictCursor
|
||||
)
|
||||
def get_db():
|
||||
connection = pymysql.connect(
|
||||
host=host,
|
||||
user=user,
|
||||
password=password,
|
||||
database=database,
|
||||
charset='utf8mb4',
|
||||
cursorclass=pymysql.cursors.DictCursor
|
||||
)
|
||||
try:
|
||||
yield connection
|
||||
finally:
|
||||
connection.close()
|
||||
|
||||
cursor = connection.cursor()
|
||||
# cursor = connection.cursor()
|
||||
# cursor.execute(sql, ())
|
||||
# cursor.fetchall()
|
||||
# connection.commit()
|
||||
Reference in New Issue
Block a user