mysql导入csv文件,与python连接
2016-04-01 11:30
489 查看
csv文件导入mysql数据库表中:
load data infile 'F:/eclipse2/tianchi_fresh_comp_train_user.csv'
into table `shopping_records_original`
fields terminated by ',' optionally enclosed by '"' escaped by '"'
lines terminated by '\n';
数据库表导出到csv文件:
select * from `shopping_records_original`
into outfile 'F:/eclipse2/tianchi_fresh_comp_train_user.csv'
fields terminated by ',' optionally enclosed by '"' escaped by '"'
lines terminated by '\n';
python连接mysql数据库:
load data infile 'F:/eclipse2/tianchi_fresh_comp_train_user.csv'
into table `shopping_records_original`
fields terminated by ',' optionally enclosed by '"' escaped by '"'
lines terminated by '\n';
数据库表导出到csv文件:
select * from `shopping_records_original`
into outfile 'F:/eclipse2/tianchi_fresh_comp_train_user.csv'
fields terminated by ',' optionally enclosed by '"' escaped by '"'
lines terminated by '\n';
python连接mysql数据库:
import pymysql conn = pymysql.connect(user='root', passwd='root', host='localhost', db='zjctest') cur = conn.cursor() cur.execute("SELECT * FROM zjc") for r in cur: print("row_number:" , (cur.rownumber) ) print("id:"+str(r[0])+"name:"+str(r[1])+"age:"+str(r[2])) cur.close() conn.close()
相关文章推荐
- python 学习笔记(2)
- Selenium+Python windows下环境搭建
- Python 学习文章收藏
- python语言学习3 ——第一个python程序
- python中的运算符
- python3抓取百度贴吧帖子
- java 中使用 python外部扩展包pycha
- 初学python(对比java语言不同) 第一篇
- python psutil监控进程
- python语言学习2——安装python
- leetcode-06-zigzag conversion-python
- Python之类
- python常用绘图软件包记录
- python中数据的保存
- 利用Anaconda安装python后,如何安装opencv-python
- Python/Keras如何将给定的数据集打乱
- Python如何进行cross validation training
- Python常用函数
- Python如何读取指定文件夹下的所有图像
- python相关的工具