创建数据库以及表,并导入数据
--创建数据库
CREATE DATABASE `data` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
--创建表
--win w 胜 0 分数 1 比分
--draw d 平
--lose l 负
CREATE TABLE `data`(
`ID` int(18) NOT NULL AUTO_INCREMENT,
`scr` char(100) NOT NULL,
`hos` char(100) NOT NULL,
`gue` char(100) NOT NULL,
`w10` float(5,2) NOT NULL,
`w20` float(5,2) NOT NULL,
`w21` float(5,2) NOT NULL,
`w30` float(5,2) NOT NULL,
`w31` float(5,2) NOT NULL,
`w32` float(5,2) NOT NULL,
`w40` float(5,2) NOT NULL,
`w41` float(5,2) NOT NULL,
`w42` float(5,2) NOT NULL,
`w50` float(5,2) NOT NULL,
`w51` float(5,2) NOT NULL,
`w52` float(5,2) NOT NULL,
`wot` float(5,2) NOT NULL,
`d00` float(5,2) NOT NULL,
`d11` float(5,2) NOT NULL,
`d22` float(5,2) NOT NULL,
`d33` float(5,2) NOT NULL,
`dot` float(5,2) NOT NULL,
`l01` float(5,2) NOT NULL,
`l02` float(5,2) NOT NULL,
`l12` float(5,2) NOT NULL,
`l03` float(5,2) NOT NULL,
`l13` float(5,2) NOT NULL,
`l23` float(5,2) NOT NULL,
`l04` float(5,2) NOT NULL,
`l14` float(5,2) NOT NULL,
`l24` float(5,2) NOT NULL,
`l05` float(5,2) NOT NULL,
`l15` float(5,2) NOT NULL,
`l25` float(5,2) NOT NULL,
`lot` float(5,2) NOT NULL,
PRIMARY KEY (`ID`)
)
;
--导入数据
--导入到Mysql数据库中
import MySQLdb as mdb
conn=mdb.connect(host='localhost',user='root',passwd='oracle',db='betdb',port=3306)
cur = conn.cursor()
SQL="insert into data(scr,hos,gue,w10,w20,w21,w30,w31,w32,w40,w41,w42,w50,w51,w52,wot,d00,d11,d22,d33,dot,l01,l02,l12,l03,l13,l23,l04,l14,l24,l05,l15,l25,lot) values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
l =len(alldata)/34
for i in range(l):
for item in alldata[34*i:34*i+1]:
cur.execute(SQL,alldata[34*i:34*i+34])
i+=1