pip install web.py==0.40.dev0
import pymysql
pymysql.install_as_MySQLdb()
import web
db = web.database(dbn='mysql', host='db_host', port=3306,
user='root', pw='password', db='db_name', charset='utf8')
results = db.query('select * from user where id = 1;')
for user in results:
print(user.name)
print(user.id_no)
欢迎光临 重工电子论坛 (http://cqutlab.cn/) | Powered by Discuz! X3.1 |