可以在flask中查看markdown代码
Project description
导入方法
pip install mongodb_to_other
一.mongodb转xls
1.1注意事项
请确保自己的mongodb为此格式
加粗的可以自行更改
testdb
collections
userdb
1.2 导入
from mongodb_to_other import mongodb_to_xls
1.3使用
from mongodb_to_other import mongodb_to_xls
#倒库
mongodb_to_xls("数据名","集合名","xls文件路径",port=int('数据库端口(默认为27017)'),ip="mongodb数据库所在的ip地址(默认为127.0.0.1)",name="数据库用户名(默认为None)",password="数据库密码(默认为None)")
在上面代码中 mongodb_to_xls 函数有三个必要值,第一个值为数据库的名称,第二个值为数据库中collections文件夹下要转换的集合,第三个值为要输出的文件地址
二.mongodb转json
2.1简介
注意事项与mongodb转xls一样 这一个模块主要是为了windows用户设计 因为windows用户无法使用mongodb的导出工具
2.2导入
from mongodb_to_other import mongodb_to_json
2.3使用
from mongodb_to_other import mongodb_to_json
#倒库
mongodb_to_json("数据名","集合名","xls文件路径",port=int('数据库端口(默认为27017)'),ip="mongodb数据库所在的ip地址(默认为127.0.0.1)",name="数据库用户名(默认为None)",password="数据库密码(默认为None)")
在上面代码中 mongodb_to_xls 函数有三个必要值,第一个值为数据库的名称,第二个值为数据库中collections文件夹下要转换的集合,第三个值为要输出的文件地址
三.mongodb转my_sql
3.1注意事项
- 转换后mysql会变为如下
表名: mongodb中的set_name
--------------------------------------
| _id(mongodb中的id) | key | key |
--------------------------------------
| xxxxxxxxxxxxxxxxx | value | value |(第一条)
--------------------------------------
| xxxxxxxxxxxxxxxxx | value | value |(第二条)
--------------------------------------
-
请注意mysql数据库中没有与mongodb中的set_name相同的表,如果有重复会报错
-
请注意mysql默认为3306端口无法改变
-
请注意mysql必须要有用户
3.2导入
from mongodb_to_other import mongodb_to_mysql
3.3使用
from mongodb_to_other import mongodb_to_mysql
#倒库
mongodb_to_json("mongodb数据名","mongodb集合名","mysql数据库名","mysql用户名","mysql用户密码",s_ip="你的mysql数据库ip(默认为127.0.0.1)",port=int('mongodb数据库端口(默认为27017)'),ip="mongodb数据库所在的ip地址(默认为127.0.0.1)",name="mongodb数据库用户名(默认为None)",password="mongodb数据库密码(默认为None)")
给个星星吧
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mongodb_to_other-0.2.2.tar.gz
(6.0 kB
view hashes)