zzck/table_init.py

18 lines
491 B
Python

from config import *
import pymysql
import json
import logging
import datetime
conn = pymysql.connect(
host=MYSQL_HOST_APP,
port=MYSQL_PORT_APP,
user=MYSQL_USER_APP,
password=MYSQL_PASSWORD_APP,
db=MYSQL_DB_APP,
charset='utf8mb4'
)
with conn.cursor() as cursor:
with open('schema.sql', 'r') as schema_file:
create_table_sql = schema_file.read().replace('\n', ' ') # Remove line breaks
cursor.execute(create_table_sql)