All Projects → Relrin → sanic-mongodb-extension

Relrin / sanic-mongodb-extension

Licence: BSD-3-Clause License
MongoDB with μMongo support for Sanic framework

Programming Languages

python
139335 projects - #7 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to sanic-mongodb-extension

sanic-plugin-toolkit
Easily create Plugins for Sanic!
Stars: ✭ 49 (+96%)
Mutual labels:  extension, sanic
Asyncorm
Fully Async ORM inspired in django's
Stars: ✭ 182 (+628%)
Mutual labels:  orm, sanic
aurora
The project based sanic
Stars: ✭ 44 (+76%)
Mutual labels:  sanic
CSEDevOps
Azure DevOps extensions from CSE DevOps team
Stars: ✭ 18 (-28%)
Mutual labels:  extension
vscode-gitignore
A simple extension for Visual Studio Code that lets you pull .gitignore files from the https://github.com/github/gitignore repository
Stars: ✭ 44 (+76%)
Mutual labels:  extension
easy-es
Better Elastic Search search engine framework, the bottom layer adopts RestHighLevelClient, API design consistent with Mybatis-plus, zero additional learning cost, shielding language differences, developers only need to know MySQL syntax to complete Es-related operations, both Low code, easy to use, easy to expand and other features, support Es …
Stars: ✭ 218 (+772%)
Mutual labels:  orm
pinipig
🚀 Performant webservice framework
Stars: ✭ 25 (+0%)
Mutual labels:  orm
cake-vso
Cake integration for Azure DevOps.
Stars: ✭ 19 (-24%)
Mutual labels:  extension
feathers-objection
Feathers database adapter for Objection.js, an ORM based on KnexJS SQL query builder for Postgres, Redshift, MSSQL, MySQL, MariaDB, SQLite3, and Oracle. Forked from feathers-knex.
Stars: ✭ 89 (+256%)
Mutual labels:  orm
Linkaro
A browser extension to easily store your social links and share them from right within your browser.
Stars: ✭ 31 (+24%)
Mutual labels:  extension
pyhikvision
hikvision-sdk for Python3 in action
Stars: ✭ 141 (+464%)
Mutual labels:  orm
AndroidSDKSearchExtension-Firefox
A Firefox port of the Chrome extension that adds an 'ad' Awesome Bar command and view source links for the Android SDK.
Stars: ✭ 19 (-24%)
Mutual labels:  extension
laravel-msaccess
Laravel ORM for Microsoft Access DB
Stars: ✭ 31 (+24%)
Mutual labels:  orm
AntiRickRoll
Chrome extension that blocks Rickrolls!
Stars: ✭ 22 (-12%)
Mutual labels:  extension
awesome-go-orms
ORMs for Go, most starred on Github.
Stars: ✭ 206 (+724%)
Mutual labels:  orm
Userscript
Userscripts collection written by me
Stars: ✭ 92 (+268%)
Mutual labels:  extension
wasm-extension-template
An easy-to-use template for Rust web extensions. The Rust code is compiled to WASM and ran as a content script.
Stars: ✭ 78 (+212%)
Mutual labels:  extension
java-bible
🍌 我的技术摘要
Stars: ✭ 2,950 (+11700%)
Mutual labels:  orm
phper
A library that allows us to write PHP extensions using pure Rust and using safe Rust whenever possible.
Stars: ✭ 24 (-4%)
Mutual labels:  extension
urbit-visor
Urbit Visor is an extension which transforms your web browser into a first class Urbit client.
Stars: ✭ 65 (+160%)
Mutual labels:  extension

sanic-mongodb-extension

MongoDB with μMongo ODM support for Sanic framework

Features

  • Uses motor_asyncio package for async queries to MongoDB
  • Good integrated with uMongo ODM, so that you can use it easily in your projects

Installation

This package should be installed using pip:

pip install sanic-mongodb-extension

Example

#!/usr/bin/env python3
from sanic import Sanic, response
from sanic_mongodb_ext import MongoDbExtension
from umongo import Instance, Document, MotorAsyncIOInstance
from umongo.fields import StringField


app = Sanic(__name__)
# Configuration for MongoDB and uMongo
app.config.update({
    "MONGODB_DATABASE": "app", # Make ensure that the `app` database is really exists
    "MONGODB_URI": "mongodb://root:root@mongodb:27017",
    # You can also specify custom connection options.
    # For more details check the official docs: https://api.mongodb.com/python/3.7.0/api/pymongo/mongo_client.html#pymongo.mongo_client.MongoClient
    "MONGODB_CONNECT_OPTIONS: {
        "minPoolSize": 10,
        "maxPoolSize": 50,
    },
    "LAZY_UMONGO": MotorAsyncIOInstance(),
})
# uMongo client is available as `app.mongodb` or `app.extensions['mongodb']`.
# The lazy client will be available as `app.lazy_mongodb` only when the database was specified,
# and which is a great choice for the structured projects.
MongoDbExtension(app)


# Describe the model
@app.lazy_umongo.register
class Artist(Document):
    name = StringField(required=True, allow_none=False)


# And use it later for APIs
@app.route("/")
async def handle(request):
    artist = Artist(name="A new rockstar!")
    await artist.commit()
    return response.json(artist.dump())


if __name__ == '__main__':
    app.run(host='0.0.0.0', port=8000)

License

The sanic-mongodb-extension is published under BSD license. For more details read LICENSE file.

Real project examples

Open Matchmaking project:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].