Skip to main content

LightMagic is very simple and quick python3 ORM over momoko/psycopg2.

Project description

LightMagic is very simple and quick python3 ORM over momoko/psycopg2.

Введение

LightMagic - это простая и быстрая (условно) ORM система для Postgres.

Система позволяет использовать ограниченный набор запросов для конкретной модели, в частности:

* create()
* get_list()
* load()
* remove()
* upsert()

и использовать оператор join() для нескольких моделей.

При необходимости Вы можете легко расширить свою модель дополнительными методами.

LightMagic изначально разрабатывалась как ORM для Tornado + Postgres, но Вы так же можете использовать одни и те же модели и для обычных (синхронных) скриптов (например cron).

Простой вариант использования:

import LightMagic.types as types
from LightMagic.db.Model import Model
class ExampleClass(Model):
    """Just Example Class"""
    id = types.Int(value=3, allow_none=False, db_primary_key=True, db_autovalue=True)
    region = types.Str(allow_none=False, db_primary_key=True, db_autovalue=False, db_default_value='Moscow')
    name = types.Str(min_length=3, max_length=10)
    name_2 = types.Str(regexp=re.compile('^[a-z]{1,3}$'))
    cdate = types.DateTime(db_default_value='NOW()')
    udate = types.DateTime(db_default_value='NOW()')
    params = types.Json(db_default_value='{}')
    list = types.List(type_of_elements=int, db_type=None)
    uuid4 = types.UUID4()
    pan = types.CardPan()
    enum = types.Enum(list_of_values=('a', 1, 10, 8))
    lang = types.Language()
    email = types.Email()
    secret_string = types.CryptoAES(secret_key='qnflslglslvn3ogl', initialization_vector='fhwkfnwifh3hfhsh')

    def get_table_name(self):
        return 'test.table'

License

LightMagic is distributed under the MIT license http://www.opensource.org/licenses/mit-license.php

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

LightMagic-0.1.20.tar.gz (18.9 kB view details)

Uploaded Source

File details

Details for the file LightMagic-0.1.20.tar.gz.

File metadata

  • Download URL: LightMagic-0.1.20.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for LightMagic-0.1.20.tar.gz
Algorithm Hash digest
SHA256 db0e324bf5acfbee0703a81f9fbbefc2f997d5af7a4e40010636d8a4b8973604
MD5 2bf1e53e5fdd9ae9948e3601ed8a2ecb
BLAKE2b-256 f06a8f431a8ad8139549b0923ec94bac34ce6c05055d3f175f6ab36901338fcf

See more details on using hashes here.

Supported by

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