西奥-数据库
theo-database的Python项目详细描述
theo数据库
它是一个易于控制数据库的数据库。
MongoDB由控制MongoDB的方法组成。
我很可能在等待任何形式的贡献。
西奥系列
框架:pip安装theo框架,https://github.com/TheodoreWon/python-theo-framework
数据库:pip安装theo数据库,https://github.com/TheodoreWon/python-theo-database
消息:pip install theo消息,https://github.com/TheodoreWon/python-theo-message
互联网:pip安装theo消息,https://github.com/TheodoreWon/python-theo-internet
trade:pip安装theo trade,https://github.com/TheodoreWon/python-theo-trade
如何使用
安装框架
pip install theo-database
打印文档字符串
from theo.database import MongoDB, MongoDBCtrl
print(MongoDB.__doc__)
print(MongoDBCtrl.__doc__)
简单示例
''' import theo-database, MongoDB '''
from theo.database import MongoDB
mongodb = MongoDB(check_connection=True)
''' print databases '''
databases = mongodb.get_databases()
print('databases:{}'.format(databases))databases:['Athena', 'admin', 'config', 'local']
''' print collections '''
for database in databases:
collections = mongodb.get_collections(database)
print('database({}) collections:{}'.format(database, collections))database(admin) collections:['system.version']
database(config) collections:['system.sessions']
database(local) collections:['startup_log']
''' print existence '''
print('theo-database/example exist:{}'.format(mongodb.is_database_exist('theo-database')))
print('theo-database/example exist:{}'.format(mongodb.is_collection_exist('theo-database', 'example')))theo-database/example exist:False
theo-database/example exist:False
''' save and load data '''
mongodb.insert('theo-database', 'example', [{'text': 'Hello, theo-database.'}, {'text': 'Thank you for using.'}])
print('theo-database/example exist:{}'.format(mongodb.is_database_exist('theo-database')))
print('theo-database/example exist:{}'.format(mongodb.is_collection_exist('theo-database', 'example')))
print(mongodb.select('theo-database', 'example'))theo-database/example exist:True
theo-database/example exist:True
[{'text': 'Hello, theo-database.'}, {'text': 'Thank you for using.'}]
''' drop collection '''
mongodb.drop_collection('theo-database', 'example')
print('theo-database/example exist:{}'.format(mongodb.is_database_exist('theo-database')))
print('theo-database/example exist:{}'.format(mongodb.is_collection_exist('theo-database', 'example')))theo-database/example exist:False
theo-database/example exist:False
如何设置MongoDB
第一步。下载
Open the website, https://www.mongodb.com/
Find and click the 'Get MongoDB' button from top of the page
Select 'Server' of the list Cloud, Server, Tools
Check the environment, Version, OS, Package and click the 'Download' button
第二步。安装
Execute the installer what is downloaded
Follow the install steps and un-check 'Install MongoDB Compass'
第三步。在Windows中将MongoDB设置为服务
Make new folder like C:\Users\wonta\mongodb
Run cmd (command prompt) as Administrator
Go to the MongoDB location like C:\Program Files\MongoDB\Server\4.0\bin
Enter the command 'mongod --remove'
Enter the command 'mongod --dbpath=C:\Users\wonta\mongodb --logpath=C:\Users\wonta\mongodb\log.txt --install'
Restart the windows
作者
Theodore Won-该项目的所有者
许可证
此项目是根据麻省理工学院的许可证授权的-有关详细信息,请参见许可证文件
版本控制
基本上,这个项目遵循“语义版本控制”。(https://semver.org/)
但是,为了通知新特性,我在语义版本控制中添加了几个简单的规则。
我想叫“Theo版本控制”。
- 版本格式为major.minor.patch
- 当api改变或提供新特性时,主版本会增加。
- 新功能不影响界面。
- 但是,为了通知新特性,新特性会生成主版本。
- 在正式版本发布(1.0.0)之前,主版本保持为0,次版本使用。
- 添加API时,次要版本已启动。(新功能)
- 修补程序版本在修复错误、上载测试代码、更新注释或文档或日志时解除。