#coding=utf-8
'''
Created on 2016年2月20日
将xml获取的数据读取出来,存入mysql
读取xml内容的参考文档:http://www.cnblogs.com/fnng/p/3581433.html
将内容写入mysql的参考文档:http://www.cnblogs.com/rollenholt/archive/2012/05/29/2524327.html
@author: cf
'''
import MySQLdb
from xml.etree import ElementTree as ET
per=ET.parse("vidio.xml")
p=per.findall('./vidio')
conn=MySQLdb.connect(
host='localhost',
port=3306,
user='root',
passwd='cf168077,.',
db='test',
charset='utf8'
)
cur=conn.cursor()
cur.execute('create table vidio(vidioUrl varchar(100),vidioName varchar(100),vidioKind varchar(100),vidioDuration varchar(100),vidioPublish varchar(100),vidioStyle varchar(100),vidioDirector varchar(100),vidioWriters varchar(100),vidioStars varchar(100),vidioImage varchar(1000),vidioDescription varchar(1000))')
for oneper in p:
python【番外篇】:将xml中的数据写入到mysql中
最新推荐文章于 2024-04-14 10:10:09 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)