A simple and lightweight ORM that facilitate some operations on SQL Server using of pyodbc.
Project description
About
A simple and lightweight ORM that facilitate some operations on SQL Server using of pyodbc.
How to use
Preparation
# Single call it once to setup the inner settings
BetterMSSQL.setup("name of the database", "db user", "db password", "host", 1234) #port
# Creating a DB Model
class Fruits():
_table = "fruit_table_name"
class People():
_table = "people_table_name"
Select
# Select the first fruit ordered by name and retrieve the first row
Fruits().select("name").order("name").row() # returns one row
# Select all data from the top 15 fruits
Fruits().select("*").top("15").run() # returns a row list
# Select all data from the top 15 fruits
Fruits().select("*").top("15").run() # returns a row list
# Select the name of the first person with 34 years old
People().select("name").where("age = ?").cell(34) # returns the first cell of the first row
Insert
# Inserting a person given its name and age
People().insert("name, age").run(["Matt", 34])
Update
# Updating all ages to 16 where the name is Matt
People().update("age = ?").where("name = ?").run([16, "Matt"])
Delete
# Delete all persons
People().delete()
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
bettermysql-0.0.1.tar.gz
(3.5 kB
view hashes)
Built Distribution
Close
Hashes for bettermysql-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 429cc6334cb51573c18cbec9db6cd0bead88186cdcf87c14f67cbc7f15e58bd5 |
|
MD5 | 75e1446483d24e450edfb27ab8702d5d |
|
BLAKE2b-256 | 31d1f788d8f0ff78b86682ec68c653a4d82ead2bd77be4280594fb3d5e11ed44 |