Package: kemampo
KemampoSmall, Lightweight Library to cut down SQLAlchemy Controllers BoilerplatesUsageConceptFirst define all of your tables, and all things necessaryinstead of implementing custom Controllers that handle errors and what not. you can use Kemampo to cut downs all of the Boilerplates. so all you need to do next is: implement sqlalchemy'ssessionmakerand pass it into Kemampo intializeruse Kemampo to generate all the basicCRUDcontrollers.Use it as is. or add it to your custom Controller class usingsetattrExampleDefine your tableDB_ENGINE=create_engine("sqlite:///",pool_pre_ping=True,echo=False,)DB_BASE=declarative_base(bind=DB_ENGINE)metadata=DB_BASE.metadataclassUser(DB_BASE):__tablename__="user"id=Column(Integer,primary_key=True)username=Column(String(16),nullable=False,unique=True)password=Column(String(128),nullable=False)Use KemampofromkemampoimportKemampokemampo=Kemampo(sessionmaker(bind=DB_ENGINE))UserController=kemampo.generate_controller(User)user_data={"username":"test_new_user","password":"a_password_hash"}update_user_data={"username":"updated_username"}status,user=UserController.add(**new_user_data)# create new userstatus,users=UserController.get(id=1)# get by idstatus,user=UserController.update_by_id(1,**update_user_data)# update by idstatus,users=UserController.get_all()# get allstatus,user=UserController.delete(1)# delete by idInstallationYou can install via PyPIpython3-mpipinstallkemampoAPI Documentationskemampo.Kemampo(session_maker, log_callback)ConstructorsessionmakerExpected Type:sqlalchemy.orm.session.sessionmakerYour own sessionmaker. docs:https://docs.sqlalchemy.org/en/13/orm/session_api.html#session-and-sessionmakerlog_callbackExpected Type:Callbacksorfunctionput your function here to get kemampo logging outputMethodsKemampo.generate_controller(target_model)The Main feature of kemampo, create aCRUDcontroller fortarget_modeltarget_modelExpected Type:your tablespecificallysqlalchemy.ext.declarative.DeclarativeMetaor it's subclassreturns<table-name>Controller<table-name>ControllerThe core feature of Kemampo, provide you with basicCRUDController OperationsMethodsadd(**table_dict_model)Add new row data to databasetable_dict_modeltype:Dictscheme:{table_column_name:column_name_value,...}returns Tuple of:(True,added_dict_of_model) or(False,ReturnStatus)get(**target_row_column_key_value)Get rows data from database, based on column name you give with certain value. support multiple column name and valuetarget_row_column_key_valuetype:Dictscheme:{table_column_name:column_name_value,...}returns Tuple of:(True,List[dict_of_model]) or(False,ReturnStatus)get_all()Gather all row values from databasereturns Tuple of:(True,List[dict_of_model]) or(False,ReturnStatus)update_by_id(target_id, **updated_row_column_key_value)target_idtype:intupdated_row_column_key_valuetype:Dictscheme:{table_column_name:column_name_value,...}returns Tuple of:(True,dict_of_model) or(False,ReturnStatus)delete(**target_row_column_key_value)target_row_column_key_valuetype:Dictscheme:{table_column_name:column_name_value,...}returns Tuple of:(True,dict_of_model) or(False,ReturnStatus)ReturnStatusan Enumeration of possible Errors happening inside KemampoReturnStatus.DatabaseErrorError happened internallyValues:str->"Database Error"ReturnStatus.NotFoundTargeted row data was not found inside databaseValues:str->"Row Data Not Found"