NoSQL object model database
Project description
Firebase ORM Python
Django like models for NoSQL database Firestore.
Installation
$ pip install firebase_orm
Initialize
Create settings.py in the root directory of the project:
settings.py
CERTIFICATE = 'path/to/serviceAccountKey.json' BUCKET_NAME = '<BUCKET_NAME>.appspot.com'
- CERTIFICATE
Once you have created a Firebase console project and downloaded a JSON file with your service account credentials.
- BUCKET_NAME
The bucket name must not contain gs:// or any other protocol prefixes. For example, if the bucket URL displayed in the Firebase console is gs://bucket-name.appspot.com, pass the string bucket-name.appspot.com
Usage
Create model:
from firebase_orm import models
class Article(models.Model):
headline = models.CharField()
type_article = models.CharField(db_column='type')
class Meta:
db_table = 'medications'
def __str__(self):
return self.headline
Use API:
# Import the models we created
>>> from models import Article
# Create a new Article.
>>> a = Article(headline='Django is cool')
# Save the object into the database. You have to call save() explicitly.
>>> a.save()
# Now it has an ID.
>>> a.id
1
# Fields are represented as attributes on the Python object.
>>> a.headline
'Django is cool'
# Firebase ORM provides a rich database lookup API.
>>> Article.objects.get(id=1)
<Article: Django is cool>
>>> Article.objects.get(id=2)
Traceback (most recent call last):
...
DoesNotExist: Article matching query does not exist.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for firebase_orm-0.1.0-py36-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 168c1bed93af7cb7c46ea9f276dcd171854e287f2859ad9b9d4c4f150ad8be3a |
|
MD5 | 67ce203ab02367100b2d746328834ac7 |
|
BLAKE2b-256 | 756599d23155e0e69aa7eaa31006344b71856158269bb570fe2788916d91ab0d |