当前位置: 移动技术网 > IT编程>脚本编程>Python > 文件(csv/xslx)中的数据导入到数据库中

文件(csv/xslx)中的数据导入到数据库中

2020年04月09日  | 移动技术网IT编程  | 我要评论

月度工作总结ppt,欧派整体厨房,商业服务业设施用地

*.sql文件导入数据库通常比较方便。

其他格式如csv、xsl等文件导入比较费劲。

推荐一个针对csv\xsl的导入工具:

如果文件第一行是table的字段名,自动建表+导入数据,实在是省事。

具体用法请看readme:

load data from csv/xlsx into database(mysql/postgresql)

install

  • pipenv install #或者
  • pip install -r requirements.txt

config

  • $sudo touch .env
database_uri=postgresql+psycopg2://admin:1234@localhost/test

usage

  • python file_to_db.py -h
usage: file_to_db.py [-h] [--file file] [--table table]

optional arguments:
  -h, --help            show this help message and exit
  --file file, -f file  the file path.
  --table table, -t table
                        the table name.

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网