Skip to main content

Easy ORM package

Project description

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()

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

pypyorm-0.1.1.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pypyorm-0.1.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file pypyorm-0.1.1.tar.gz.

File metadata

  • Download URL: pypyorm-0.1.1.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for pypyorm-0.1.1.tar.gz
Algorithm Hash digest
SHA256 bf3d09dfdc0015a40be4548e5893382b1125ad9900ce04cf25f75625ff396e50
MD5 139ce3212338d6c548c937d2b3bb05aa
BLAKE2b-256 375e02e178aafebe66bfef53b06ed0cbd0a8d801c4308128de06d45677793157

See more details on using hashes here.

File details

Details for the file pypyorm-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pypyorm-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for pypyorm-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 54eaefaa45e10b700cbbd396025d489693a9a5d903bbd4c1318f083e1821ec21
MD5 a9d02c4f591cde2a5318b60787452714
BLAKE2b-256 33f2961f67a141ea6f614cb903c42f41e716baa0cdbd456d19f4d95c760120a3

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