import pymysql

h, pt, u, p, db = 'rm-2zeoye0j3957bw1w2.mysql.rds.aliyuncs.com', 3306, 'tongji_2017', 't3o5N7g7j2I', 'direct_ad'
h, pt, u, p, db = '100.118.74.223', 3306, 'tongji_2017', 't3o5N7g7j2I', 'direct_ad' h, pt, u, p, db = 'localhost', 3306, 'root', 'root', 'xl_product_DONOT_REMOVE' def mysql_fetch(sql, res_type='tuple'):
global h, pt, u, p, db
try:
conn = pymysql.connect(host=h, port=pt, user=u, passwd=p, db=db, charset='utf8')
except Exception as e:
print(e)
return ()
if res_type == 'dic':
cursor = conn.cursor(pymysql.cursors.DictCursor)
else:
cursor = conn.cursor()
cursor.execute(sql)
conn.commit()
cursor.close()
conn.close()
return cursor.fetchall() def mysql_write(sql):
global h, pt, u, p, db
try:
conn = pymysql.connect(host=h, port=pt, user=u, passwd=p, db=db, charset='utf8')
except Exception as e:
print(e)
return 1
cursor = conn.cursor()
cursor.execute(sql)
conn.commit()
cursor.close()
conn.close()
return 0 sql = 'SELECT url FROM ad_direct_order LIMIT 1'
sql = 'SELECT url FROM chk_url_404 LIMIT 1'
d = mysql_fetch(sql)
ff = 0

  

05-26 20:41