python读写数据库
老方法
创建数据库连接
def __init__(self, host, user, passwd, db, port): self.conn = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db, port=port, charset='utf8') self.conn.autocommit(True) self.cur = self.conn.cursor()
读写、执行语句
def shop_getbalance(self,supplierId): query = "select * from db.table_a" self.mysql.cur.execute(query)
用SQLAlchemy
to be continue