Package: rdbms
RDBMSRelational Database Management SystemInstallingInstall and update usingpip3:$ pip3 install rdbmsPython 3 and newer.Simple UsagefromrdbmsimportRDBMSclassUser(RDBMS):path='./test_sqlite.db'# default in-memory usagedefsetup(self):"""
        CREATE TABLE IF NOT EXISTS  user
        (
         id INTEGER   PRIMARY KEY   AUTOINCREMENT,
         name         TEXT          NOT NULL UNIQUE,
         password     CHAR(200)
         );
        """defcreate_user(self,name,password):"""
        INSERT INTO user (name, password)
        VALUES ('{name}', '{password}')
        """defget_user(self,name):"""
        SELECT * FROM user
        WHERE name = '{name}'
        """defexecute_script_example(script=True):"""
       Run script
       """if__name__=='__main__':user=User()user.create_user(name='username',password='1234')users=user.get_user(name='username')assertusers[0].name=='username'assertusers[0].name==users[0]['name']Parameters ExamplefromrdbmsimportRDBMSclassTest(RDBMS):defsetup(self):# not required | script parameter defaults to True for setup function"""
        Some SQL script
        """defscript_execute(self,script=True):# run script | script default False"""
        Some SQL script
        """defiterable_object(self,iterable=True):# return generator | iterable default False"""
        Some SQL query
        """deffixed_size(self,size=1):# fixed size data return | size default None"""
        Some SQL query
        """Function ExamplefromrdbmsimportRDBMSdeftitlecase(text):returntext.title()classTest(RDBMS):...defget_test_function_data(self,data):"""
        SELECT titlecase(name) FROM test WHERE name='{data}'
        """if__name__=='__main__':test=Test()test.add_function(titlecase)result=self.test.get_test_function_data(data='test name')assertresult[0].name=='Test Name'Aggregate ExamplefromrdbmsimportRDBMSclassmysum:def__init__(self):self.count=0defstep(self,value):self.count+=valuedeffinalize(self):returnself.countclassTest(RDBMS):...defget_test_aggregate_data(self):"""
        SELECT mysum(age) FROM test
        """if__name__=='__main__':test=Test()test.add_aggregate(mysum)result=test.get_test_aggregate_data()assertresult[0]['mysum(age)']==100Collaction ExamplefromrdbmsimportRDBMSdefcollate_reverse(string1,string2):ifstring1==string2:return0elifstring1<string2:return1else:return-1classTest(RDBMS):...defget_test_collation_data(self):"""
        SELECT name FROM test ORDER BY name COLLATE collate_reverse
        """if__name__=='__main__':test=Test()test.add_collaction(collate_reverse)result=test.get_test_collation_data()assertresult[0]['name']=='b'assertresult[1]['name']=='a'Text Factory ExamplefromrdbmsimportRDBMSfromrdbms.text_factoriesimporttext_factory_bytesclassTest(RDBMS):...if__name__=='__main__':test=Test()test.set_text_factory(text_factory_bytes)data=test.get_data()assertresult[0].attribute,bytesRow Factory ExamplefromrdbmsimportRDBMSfromrdbms.text_factoriesimportdict_factoryclassTest(RDBMS):...if__name__=='__main__':test=Test()test.set_row_factory(dict_factory)data=test.get_data()assert'attribute'inresult[0]SupportPython 3.xSupports all operating systemsLinksLicense:MIT LicenseCode:https://github.com/dinceraslancom/rdbms