Skip to main content

mini mysql db orm :: miniorm

Project description


dbargkws = {'user': 'test',
'password': 'test',
'host': 'localhost',
'port': "3306",
'database': 'test',
'autocommit': False,
'charset': 'utf8'

from miniorm import Model
user_model = Model.make("User", dbargkws, "users") #users is db tablename

s = user_model.get_by_map({"id":}, select_cols=["id", 'name'])

select like
s = user_model.get_by_map({"id":, "name$like":"john"}, select_cols=["id", 'name'])

select gt/gte/lt/lte
s = user_model.get_by_map({"id$gt": 1, "name$like":"john"}, select_cols=["id", 'name'])

select order by/pagination/
s = user_model.get_by_map({"name$like":"john"}, start=0,limit=20, and_or="and", order_by=["id desc", "name"])

count distinct
usercont = user_model.count_by_map({"id$gt": 1, "name$like":"john"}, distinct="pid")

update or insert
- by namedtuple
User = namedtuple("User", ['id', 'name', 'pwd', 'email'])
user = User(None, '1', '2', "")
ins, updates, nops =

- by dict
user = {'name':"ww", 'pwd':"pwd", 'email': "xxx"}
ins, updates, nops =

uid = 1

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for miniorm, version 1.2
Filename, size File type Python version Upload date Hashes
Filename, size miniorm-1.2.tar.gz (3.3 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page