Skip to main content

Sarai Sajilo lightweight ORM inspired by Django ORM with nepali twist

Reason this release was yanked:

package is not present

Project description

Documentation

Table of Contents

Connect Database

Postgresql is the only supported Database for now(Feel free contribute to add new database)

from sajilo_orm.manager import BaseManager

MY_DB_SETTINGS = {
    "database": "db_name",
    "user": "db_user",
    "password": "db_password",
    "host": "db_host", #localhost for local connection
    "port": "5432",
}

BaseManager.DB_SETTINGS = MY_DB_SETTINGS

Create Table

To create table , import DamiModel from sajilo_orm.models and use Column class to define column along with datatype

Note: id serial primary key is added automatically when creating table

from sajilo_orm.models import DamiModel
from sajilo_orm.field import Column

class Country(DamiModel):
    table_ko_naam = "country" # this will be the name of the table created in database

    name = Column("string", max_length="50")
    no_of_province = Column("integer")
Ths won't create table yet , To create table use table banau method
    Country.bata.table_banau()

QuerySet API

Here's the list of api that you can use for executin query

Get all data
country_list = Country.bata.sabaideu()  # Returns List of Model Objects
print(country_list)

#output
#[] since there is no data yet

Add Data

For adding data in the table , use data_hala method. Table.ma.data_hala(**dataharu)

Country.ma.data_hala(name="nepal",no_of_province= 8) # will update below  
Country.ma.data_hala(name="japan",no_of_province= 37)  

# Now , if you call sabaideu

country_list = Country.bata.sabaideu()  
#[<Country :1>,<Country :2>]

# To get single object
a = country_list[0]

print(a.name,a.no_of_province)
# nepal,8

Note: Country.bata.data_hala(name="japan",no_of_province= 37) also works ma was adding cause it sounds gramatically correct than bata :sweat_smile:

Filter and Get Data

For filter , use khojera method

 filters = Team.bata.khojera(name="PSG")
For multiple column filter with 'AND' , add comma
 filters = Team.bata.khojera(name="PSG" , no_players =20)
For 'OR' filter , add an argument with value "or" before writing filter condition
 filters = Team.bata.khojera("or",name="PSG" , no_players =20)

Update Data

To Update data, we need to add id before specifying updating column If not id is provided IdXainaKanchha exception will be raised

 Country.bata.data_fera(id=1, name="Nepal", no_of_province=7)
 # this will update Country with id 1 and rest will be updated with data provided
 a = country_list[0]

 print(a.name,a.no_of_province)
# Nepal,7
Exceptions

If nothing is provided after id , then SyntaxBigryoKanchha exception will be raised

Refree.bata.data_fera(id=1) #raises SyntaxBigryoKanchha Exception

Refree.bata.data_fera(name="sinpachi") # raises IdXainaKanchha Exception

Delete Data

With this , this ORM will be able to perform simple CRUD OPERATIONS

To delete data_fala (lol) is used . Use this wisely .

   Country.bata.data_fala(id=2)
   Country.bata.data_fala(name='japan')`
   Country.bata.data_fala(no_of_provinces=')

Check if table exists

    Refree.bata.check_table_exists()
To get the use case of this orm , read the Test Case Here

Types of Exeptions

Below is the list of exception you might get using sajilo orm

  • TableVetayenaKanchha Database ma nai table navayesi aaune error !
  • ColumnNaiXainaKanchha Table ma nai navako column diyesi aaune error !
  • DatabaseConnectVayenaKanchha Database connection config namilda aaune error !
  • IdXainaKanchha Data ferda id diyena vane aaune error
  • SyntaxBigryoKanchha Syntax nai bigrexi aaune error !

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

sajilo-orm-0.0.2.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

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

sajilo_orm-0.0.2-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file sajilo-orm-0.0.2.tar.gz.

File metadata

  • Download URL: sajilo-orm-0.0.2.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for sajilo-orm-0.0.2.tar.gz
Algorithm Hash digest
SHA256 d13a18e6bdceb830d3aaa540c8987647ac18840acedd28dd2975dfe1e6ec64de
MD5 50f37e095a3d896781c5a7ef123045a8
BLAKE2b-256 3638304465b0a6177636fd34525c20dbabac0022c35aba52e1bd38048c8fe4d7

See more details on using hashes here.

File details

Details for the file sajilo_orm-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: sajilo_orm-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for sajilo_orm-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ccc0a857cd9cc3cc58eb57a910bb233b5cf72f9ab6ef987d073c013755172303
MD5 2ff3c76a6f25c2db8d31c0b301fe6a08
BLAKE2b-256 ca52a5078900b299d81a64be810516870fae67f0038dc273a41c0dfb64db7e82

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