Skip to main content

pyorm

Python ORM Module

basic

import module

from pyorm import orm

config connection

database_driver = "pymysql"
database_params = []
database_config = {
	"host": "127.0.0.1",
	"user": "root", 
	"password": "123456",
	"db": "test",
	"charset": "utf8mb4",
}
orm.config(database_driver, *database_params, **database_config)

create table

create_table_user = '''CREATE TABLE `table_user` (
	`id` int(11) NOT NULL AUTO_INCREMENT,
	`username` varchar(45) NOT NULL,
	`password` varchar(45) NOT NULL,
	`nickname` varchar(45) NOT NULL,
	`num` int(11) NOT NULL,
	PRIMARY KEY (`id`)
	) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4'''
orm.execute(create_table_user)

prefix table

orm.prefix("table_")

OrmSqlBuilder quick method

find by pk

orm.user.find(5)

add

orm.user.add(user).lastrowid

edit

orm.user.edit(user).rowcount

remove by id

orm.user.remove(11).rowcount

save

orm.user.save(user)

OrmSqlBuilder method

insert

orm.user.insert(data)

update

orm.user.where("username = ?", "admin1").update(data)

delete

orm.user.where("id = ?", 4).delete()

select where

orm.user.columns("id", "username").where("id > ", 10).where("num IN (?)", [8, 9, 10]).select().fetch_all()

group having

orm.user.group("num").select()

order

orm.user.order("num DESC", "id").select()

limit offset

orm.user.limit(10).offset(20).select()

page

orm.user.page(4, 10).select()

count

orm.user.where("id < ?", 10).count()

plus

orm.user.where("`id` = ?", 2).plus("num", 1, "num", -1)

Cursor method

fetch_all

orm.user.select().fetch_all()

fetch

orm.user.select().fetch()

fetch_one

orm.user.select().fetch_one("id")

fetch_column

orm.user.select().fetch_column("id")

fetch_unique

orm.user.select().fetch_unique("id")

fetch_key_pair

orm.user.select().fetch_key_pair("id", "username")

ORM method

insert

orm.insert("INSERT INTO `table_user` (`username`, `password`, `nickname`, `num`) VALUES (?, ?, ?, ?)", "admin1", "admin1", "admin1", 1).lastrowid

update

orm.update("UPDATE `table_user` SET `password` = ?, `nickname` = ?, `num` = ? WHERE username = ?", "admin123", "admin123", 123, "admin1").rowcount

delete

orm.delete("DELETE FROM `table_user` WHERE id = ?", 1).rowcount

select

orm.select("SELECT * FROM `table_user` WHERE id = ?", 1).fetch_all()

Metadata

Release files for pypyorm 0.1.1

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

Source distribution (sdist)

Source distribution for pypyorm 0.1.1
File Size Uploaded
pypyorm-0.1.1.tar.gz 9.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pypyorm 0.1.1
File Interpreter ABI Platform
pypyorm-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 17.7 kB

Release files / pypyorm-0.1.1.tar.gz

Download URL pypyorm-0.1.1.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
bf3d09dfdc0015a40be4548e5893382b1125ad9900ce04cf25f75625ff396e50
BLAKE2b-256 checksum
How to use checksums
375e02e178aafebe66bfef53b06ed0cbd0a8d801c4308128de06d45677793157
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5

Release files / pypyorm-0.1.1-py3-none-any.whl

Download URL pypyorm-0.1.1-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
54eaefaa45e10b700cbbd396025d489693a9a5d903bbd4c1318f083e1821ec21
BLAKE2b-256 checksum
How to use checksums
33f2961f67a141ea6f614cb903c42f41e716baa0cdbd456d19f4d95c760120a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 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