Skip to main content

Easy mase-db use mongodb, motor asyncio

Project description

Mase-DB v1.1.4

Легкое использование базы данных монгодб.

##Документация

Документация:

  • Скоро будет!

Установка

# ЕСЛИ УСТНОВЛЕН
pip install --upgrade masedb

# ЕСЛИ НЕ УСТАНОВЛЕН
python3 -m pip install --upgrade masedb

##or

pip install masedb

Применение

Предпосылки

Прежде чем приступить к работе, вам понадобится несколько вещей:

  • Установить нужные для работы библиотеки
  • Так же установить masedb
  • И понять как это все работает

И так поехали!(жабы топ)

Примеры

import masedb
from masedb.find import find_data
from masedb.insert import insert_data
from masedb.update import update_data
from masedb.delete import delete_data
import asyncio

#--------------------------------------------------------------------------------------------------------------------------------------------------------

#await find_data(url=url.uri, DatabaseName=DatabaseName, CollectionName=CollectionName, param={'name': 'mark'})
#await insert_data(url=url.uri, DatabaseName=DatabaseName, CollectionName=CollectionName, param={'name': 'mark'})
#await update_data(url=url.uri, DatabaseName=DatabaseName, CollectionName=CollectionName, param1={'name': 'mark'}, param2={'$set':{'let': 10}})
#await delete_data(url=url.uri, DatabaseName=DatabaseName, CollectionName=CollectionName, param={'cash': 10})

#--------------------------------------------------------------------------------------------------------------------------------------------------------

#     Название базы данных и колекции

DatabaseName = 'pondb2'
CollectionName = 'poncoll2'

# Сыллка отт монгодб для подключения

url = ''

#--------------------------------------------------------------------------------------------------------------------------------------------------------

async def test():

	db = await find_data(url=url, DatabaseName=DatabaseName, CollectionName=CollectionName, param={'name': 'mark'})
	print(db)

	if not db:
		print('занесение')

		return await insert_data(url=url.uri, DatabaseName=DatabaseName, CollectionName=CollectionName, param={'name':'mark'})

	try: cash = db['cash']
	except: cash = None

	await delete_data(url=url.uri, DatabaseName=DatabaseName, CollectionName=CollectionName, param={'cash': 10})

	if not cash:
		print('update data')
		return await update_data(url=url.uri, DatabaseName=DatabaseName, CollectionName=CollectionName, param1={'name':'mark'}, param2={'$set':{'cash': 10}})

	print(cash)

asyncio.run(test())

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

masedb-1.1.4.tar.gz (3.8 kB view details)

Uploaded Source

File details

Details for the file masedb-1.1.4.tar.gz.

File metadata

  • Download URL: masedb-1.1.4.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.4

File hashes

Hashes for masedb-1.1.4.tar.gz
Algorithm Hash digest
SHA256 619437ebff64b63410408cef3005f17e3e89ecf1614093e2b98c24fa50283f38
MD5 43c5aebf3da0b1700ec49f45a5a4d462
BLAKE2b-256 d695b244fe93e091d8c9dd62467972205e03d9cb1a57e6f1335a6dc44908c7da

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page