文件(csv/xslx)中的数据导入到数据库中
*.sql文件导入数据库通常比较方便。
其他格式如csv、xsl等文件导入比较费劲。
SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。推荐一个针对csv\xsl的导入工具:https://github.com/zhengze/file_to_db.git
如果文件第一行是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.

更多精彩