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.3.7.tar.gz (19.7 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: LightMagic-0.3.7.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0

File hashes

Hashes for LightMagic-0.3.7.tar.gz
Algorithm Hash digest
SHA256 4020f63ad13473a0246c5ab1366f54831d62cf7bb2a4b28626fe0bce9429be4d
MD5 1d009b2497c66909080a8a4e73aa99e9
BLAKE2b-256 7b8a91540df17f3ee796cb59b5606d59b457dbcaa213151a74822c1578c0e296

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