来源:http://iswwwup.com/t/64d2a6747a92/mysql-python-how-to-create-multiple-tables-by-taking-a-variable-value.html
for i in range(0, len(value)):
sens_id = IDs[i]
table_drop = "DROP TABLE IF EXISTS %s" % sens_id
tabe_create = "CREATE TABLE %s (no INT NOT NULL AUTO_INCREMENT, Date DATE, tIME TIME, id CHAR(34), temperature FLOAT, PRIMARY KEY(no$
curs.execute(table_drop)
curs.execute(table_create)
sql = "INSERT INTO %s (no , date, time, ID, temperature) \
values(0, '%s', '%s', '%s', '%s')"% \
(sens_id, time.strftime("%F"), time.strftime("%X"), IDs[i], value[i] )
curs.execute(sql)
sql = []
sens_id = 0
db.commit()
db.close()
一次创建多个表