*.sql文件导入数据库一般比较方便。python
其余格式如csv、xsl等文件导入比较费劲。mysql
推荐一个针对csv\xsl的导入工具:https://github.com/zhengze/file_to_db.gitgit
若是文件第一行是table的字段名,自动建表+导入数据,实在是省事。github
具体用法请看README:sql
load data from csv/xlsx into database(mysql/postgresql)数据库
pipenv install #或者
pip install -r requirements.txt
DATABASE_URI=postgresql+psycopg2://admin:1234@localhost/test
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.