import pymysql
def connect_db(db):
db = pymysql.connect(host='xx.xx.xx.xx', port=3307, user='xxxx', passwd='xxxx', db=db, charset='utf8')
return db
def execute_sql(db, sql):
cursor = db.cursor()
cursor.execute(sql)
db.commit()
data = cursor.fetchone()
return data
def disconnect_db(db):
db.close()
if __name__ == '__main__':
db = connect_db('feed')
sql = 'select * from feed;'
res = execute_sql(db, sql)
disconnect_db(qa_db)
print(res)