Skip to main content

Torm

mongodb style orm.

mongodb,mysql are supported.

Install

git clone https://github.com/cofepy/torm
cd torm
python setup.py install

or

pip install torm

Env file

add .env file to top folder or copy one file in envs to top folder.

if database has auth, set TORM_AUTH = on/off (default off).

for example:

TORM_DB_TYPE   = mongo
TORM_DB       = test_default

TORM_HOST     = 127.0.0.1
TORM_PORT     = 27017

TORM_CHARSET  = utf8mb4

TORM_AUTH     = on
TORM_USER     = root
TORM_PASSWORD = xxx

Useage

from torm.model import Model
from torm.field import Str,Int


class Record(Model):
    # config file is ".env.mongo"; if not given, default config file is ".env".
    __configname__ = 'mongo'  

    # database type; if not given, will use db defined in config file
    # if no config file, torm will use "mongo" as default.
    __dbtype__ = 'mongo' 

    # database name: if not given, will use db defined in config file
    # if no config file, torm  will use "test" as default.
    __dbname__ = 'test'

    # table name: if not given, torm  will use the snake name of the model class name as default
    __tablename__ = 'record'

    hash = Str()
    subject = Str()
    promoter = Str()
    attachments_num = Int()
    mail_id = Str()

    commits = Str()
    group = Str()
    group_hash = Str()
    create_at = Str()
    update_at = Str()
    status = Str()
    tx_status = Str()
    recorder = Str()

# 创建
record = Record({"hash": "0x123", "subject": "test"})
Record.InsertOne(record)

# 单条查询
hash="0x123"
record = Record.FindOne(hash)
record = Record.FindOne(hash=hash)
record = Record.FindOne({'hash':hash})
print(record)
# 批量查询
records = Record.FindMany()
print(records)

Release files for torm 0.1.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for torm 0.1.9
File Interpreter ABI Platform
torm-0.1.9-py2.py3-none-any.whl Python 3, Python 2 none any Details

Release files / torm-0.1.9-py2.py3-none-any.whl

Download URL torm-0.1.9-py2.py3-none-any.whl
Size 175.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
f3aacb83ee0dc6e52508936b26d4c54235652f8a9bb5abc4a8d30c5660286780
BLAKE2b-256 checksum
How to use checksums
97e49a09efe9cc2aa43aaffda315176989a624473e735e0881d67c39748672ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.6

Release history Release notifications | RSS feed

This release

0.1.9 This release

1 release file

0.1.8

1 release file

0.1.7

3 release files

0.1.6

3 release files

0.1.5

3 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.9

3 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

1 release file

0.0.5

1 release file

0.0.4

4 release files

0.0.3

3 release files

0.0.2

2 release files

0.0.1

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page