Package: sajilo-orm
DocumentationInstallationpipinstallsajilo-ormTable of ContentsConnect DatabaseCreate TableQuerySet APIAdd DataFilter And Get DataUpdate DataDelete DataCheck If Table ExistsTypes of ExceptionConnect DatabasePostgresql is the only supported Database for now(Feel free contribute to add new database)fromsajilo_orm.managerimportBaseManagerMY_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_SETTINGSCreate TableTo create table , importDamiModelfromsajilo_orm.modelsand useColumnclass to define column along with datatype which is in NepaliNote:id serial primary keyis added automatically when creating tablefromsajilo_orm.modelsimportDamiModelfromsajilo_orm.fieldimportColumnclassCountry(DamiModel):table_ko_naam="country"# this will be the name of the table created in databasename=Column("string",max_length="50")no_of_province=Column("anka")#numbernew_year=Column("miti",default='2000-01-01')#datetoday=Column("miti",default='aja_ko_date')#gives CURRENT_DATEramro=Column("ho_ki_haina",default="ho")#booleandata=Column("string",null=False,max_length="20")#by default null=TrueHere's what data type type is behind the scenesql_type = {
    "anka":"INT ",
    "string":"VARCHAR({max_length})
    "miti":"DATE ",
    "ho_ki_haina":"BOOLEAN ",
}
(string chai nepali ma k rakhne vanera sochirako)Ths won't create table yet , To create table usetable_banaumethodCountry.bata.table_banau()QuerySet APIHere's the list of api that you can use for executing queryGet all datacountry_list=Country.bata.sabaideu()# Returns List of Model Objectsprint(country_list)#output#[] since there is no data yetAdd DataFor adding data in the table , usedata_halamethod.Table.ma.data_hala(**dataharu)Country.ma.data_hala(name="nepal",no_of_province=8,data="nice country")# will update belowCountry.ma.data_hala(name="japan",no_of_province=37,data="nice country")#default value are added# Now , if you call sabaideucountry_list=Country.bata.sabaideu()#[<Country :1>,<Country :2>]# To get single objecta=country_list[0]print(a.name,a.no_of_province)# nepal,8Note:Country.bata.data_hala(name="japan",no_of_province= 37)also worksmawas adding cause it sounds gramatically correct thanbata:sweat_smile:Filter and Get DataFor filter , usekhojeramethodfilters=Team.bata.khojera(name="PSG")For multiple column filter with 'AND' , add commafilters=Country.bata.khojera(name="nepal",no_of_province=20)For 'OR' filter , add an argument with value "or" before writing filter conditionfilters=Country.bata.khojera("or",name="japan",no_of_province=20)Update DataTo Update data, we need to addidbefore specifying updating column
If not id is providedIdXainaKanchhaexception will be raisedCountry.bata.data_fera(id=1,name="Nepal",no_of_province=7,new_year='1999-01-01')# this will update Country with id 1 and rest will be updated with data provideda=country_list[0]print(a.name,a.no_of_province,a.new_year)# Nepal,7,1999-01-01ExceptionsIf nothing is provided after id , thenSyntaxBigryoKanchhaexception will be raisedRefree.bata.data_fera(id=1)#raises SyntaxBigryoKanchha ExceptionRefree.bata.data_fera(name="sinpachi")# raises IdXainaKanchha ExceptionDelete DataWith this , this ORM will be able to perform simpleCRUD OPERATIONSTo deletedata_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 existsRefree.bata.check_table_exists()To get the use case of this orm , read theTest Case HereTypes of ExeptionsBelow is the list of exception you might get usingsajilo ormTableVetayenaKanchhaDatabase ma nai table navayesi aaune error !ColumnNaiXainaKanchhaTable ma nai navako column diyesi aaune error !DatabaseConnectVayenaKanchhaDatabase connection config namilda aaune error !IdXainaKanchhaData ferda id diyena vane aaune errorSyntaxBigryoKanchhaSyntax nai bigrexi aaune error !DateFormatMilenaKanchhaDate Format nai bigrexi aaune error !NotNullMaDataVayenaKanchhaNot Null ma Data navayesi aaune error !