Skip to main content

mongodb style python orm.

Project description


mongodb style orm.

mongodb,mysql are supported.


git clone
cd torm
python install


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_PORT     = 27017

TORM_CHARSET  = utf8mb4

TORM_AUTH     = on
TORM_USER     = root


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 = Record.FindOne(hash)
record = Record.FindOne(hash=hash)
record = Record.FindOne({'hash':hash})
# 批量查询
records = Record.FindMany()

Project details

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

torm-0.1.9-py2.py3-none-any.whl (175.4 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page