Skip to main content

Small and expressive ORM to interact with Google Datastore inspired by Django, Mongo-Engine and Peewee

Project description

No SeiQueLa ORM

IN DEVELOPMENT

🇧🇷 Documentação em Português

No SeiQueLa is a small and expressive ORM (Object Relational Mapper) to interact with Google Datastore inspired by Django, Mongo-Engine and Peewee.

Requirements

Installing

The library can be installed using pip:

pip install noseiquela_orm

Usage

Creating model classes:

from noseiquela_orm.entity import Model
from noseiquela_orm.key import Key, ParentKey
from noseiquela_orm import properties


class Customer(Model):
    name = properties.StringProperty(required=True)
    age = properties.IntegerProperty(required=True)
    is_deleted = properties.BooleanProperty(default=False, required=True)


class CustomerAddress(Model):
    __kind__ = "Address"
    __parent__ = properties.ParentKey(Customer, required=True)

    number = properties.IntegerProperty(required=True)
    address_one = properties.StringProperty(required=True)
    address_two = properties.StringProperty()
    is_default = properties.BooleanProperty(required=True)
    is_deleted = properties.BooleanProperty(default=False, required=True)

In case the project name, namespace (or any other parameter of the google.cloud.datastore.Client) needs to be changed, simply create a Meta class inside the template with the desired information.

class Product(Model):
    quantity = properties.IntegerProperty(required=True)
    name = properties.StringProperty(required=True)
    value = properties.FloatProperty(required=True)

    class Meta:
        namespace = "production"
        project = "products"

Adding new entities:

new_customer = Customer(
    name="Geraldo Castro",
    age=29,
)

new_customer.save()

new_address = CustomerAddress(
    parent_id=new_customer.id,
    number=199,
    address_one="Some St.",
    is_default=True
)

new_address.save()

Query on database:

customer = Customer.query.filter(name="Geraldo Castro").first()
customer_address = Customer.query.filter(parend_id=customer.id)

less_than_or_eq_29 = Customer.query.filter(age__le=29) # age <= 29
more_than_30 = Customer.query.filter(age__gt=30) # age > 30

all_customers = [
    customer.to_dict()
    for customer in Customer.query.all()
]

Authentication

The library uses the standard way of authenticating Google libraries (google-auth-library-python).

The search for credentials happens in the following order:

  1. If the environment variable GOOGLE_APPLICATION_CREDENTIALS is set to a valid service account path.

  2. If the Google Cloud SDK is installed and has the credentials of the application to be used, these will be loaded.

  3. If the application is running in the App Engine standard environment (first generation), then the credentials and project ID are taken from the App Identity Service.

  4. If the application is running in Compute Engine, Cloud Run, App Engine flexible environment or App Engine standard environment (second generation), then the credentials and project ID are taken from the Metadata Service.

More details at this link.

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

noseiquela_orm-0.0.2.dev0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

noseiquela_orm-0.0.2.dev0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file noseiquela_orm-0.0.2.dev0.tar.gz.

File metadata

  • Download URL: noseiquela_orm-0.0.2.dev0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for noseiquela_orm-0.0.2.dev0.tar.gz
Algorithm Hash digest
SHA256 253045b92d4b272797fe3433c09dea223c8130cf59dc4570e1e9d81acf12b8ad
MD5 066609092f8f9e0ed592d013597f69f0
BLAKE2b-256 a6c86310e0c02a6f460eb14e5ede0cfcfde48e48e575f1a011fefa0210e4d9bb

See more details on using hashes here.

File details

Details for the file noseiquela_orm-0.0.2.dev0-py3-none-any.whl.

File metadata

  • Download URL: noseiquela_orm-0.0.2.dev0-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for noseiquela_orm-0.0.2.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 816a877c6f5911af4b09206d3ff972b2e3c70413173cbb1d9318ab9367bb018a
MD5 cf0f3634ba0a22b138357f71eb556c90
BLAKE2b-256 295a82b75d455ae68b562d7320a177a7d9afc9b332358afa99b366ae26835b87

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