from aiomysql import Pool, DictCursor
from basa.db import db_pool
class dbsql():
pool: Pool = db_pool
async def register(self):
async with self.pool.acquire() as conn:
async with conn.cursor() as cur:
result = await cur.execute("SELECT * FROM profile WHERE uid")
row = await cur.fetchall()
if result == 0:
await cur.execute(f'INSERT INTO profile(uid) VALUES(uid)')
else:
return await row
main = dbsql()
import pymysql
from pymysql.constants import CLIENT
conn = {
"host": "mysql_server_hostname",
"password": "my_password",
"port": <<port_no>>,
"user": "my_username",
"client_flag": CLIENT.MULTI_STATEMENTS
}
x = '\n'.join(open('file.sql', 'r').readlines())
with pymysql.connect(**conn) as cur:
cur.execute(x)