Package: simple-db-connector
Simple_Python_DB_ConnectorPython module for simple connection and editing of databases.InstallationTo install the python module, enter the following code in the terminal. Remember, "python" must be swapped with the Python interpreter installed on your system:python-mpipinstallsimple-db-connectorUsage ExampleCall Database ClassFirst of all, we call the "database" class. Im using the os modul to call my database parameter from my environment variables. I advise you to do this straight away, as it is very bad to have sensitive data such as passwords and IP addresses in plain text:importosfromsimple_db_connectorimportdatabase# Call the database classdb=database(os.environ["db_url"],os.environ["db_user"],os.environ["db_password"],os.environ["db_port"],os.environ["db_name"],)After we have called the class, we can also use the functions of the class. All functions are self-explanatory. Nevertheless, I will briefly explain the use of each function:classdatabase.check_tableParametertable name:string# Example Table Nametable_name="test_table"# if "test_table" exists return true, otherwise return falseprint(db.check_table(table_name))It is also executed within the create_table function, so it is not necessary to execute this before you create a table.classdatabase.create_tableParametertable name:string, table content:dict# Example Table Nametable_name="cars_table"# Example Table Contenttable_content={"manufacture":"toyoat","model":"Aygo X yalp","ps":72,}# Example Table creationdb.create_table(table_name,table_content)This will create the table "cars_table" with the information contained in "test_content". In addition, a primary key field with the name "id" will be created too.  Currently this field is hard coded with a GUID field. In the near future, however, it will be possible to declare your own primary key field.classdatabase.check_db_entryParametertable:string, search_parameter:dict# Example Table Nametable_name="cars_table"# Example Search Parametersearch_parameter={"manufacture":"toyoat"}# Example Table creationdb.check_db_entry(table_name,search_parameter)This will create the table "cars_table" with the information contained in "test_content". In addition, a primary key field with the name "ID" will be created too.  Currently this field is hard coded with a GUID field. In the near future, however, it will be possible to declare your own primary key field.# Example Table Nametable_name="cars_table"# Example Search Parametersearch_parameter={"manufacture":"toyoat","model":"Aygo X yalp",}# Example Search Operatorsearch_operator=["AND"]# Example Table creationdb.check_db_entry(table_name,search_parameter,search_operator)It's also possible to have multiple search parameterclassdatabase.create_db_entryParametertable:string, data:dict, prime_key:string; default value = "id"# Example Table Nametable_name="cars_table"# Example Table Contenttable_content={"manufacture":"toyoat","model":"Aygo X yalp","ps":72,}# Example Table prime keyprime_key="id"# To illustrate this, I have entered "id". However, if "prime_key" is empty, "id" is selected.# Exampledb.create_db_entry(table_name,table_content,prime_key)classdatabase.get_db_entrysParametertable:string, search_parameter:dict# Example Table Nametable_name="cars_table"# Example Search Parametersearch_parameter={"manufacture":"toyoat"}# Example Table creationdb.get_db_entrys(table_name,search_parameter)# Example Table Nametable_name="cars_table"# Example Search Parametersearch_parameter={"manufacture":"toyoat","model":"Aygo X yalp",}# Example Search Operatorsearch_operator=["AND"]# Example Table creationdb.get_db_entrys(table_name,search_parameter,search_operator)As with check_db_entry, it is also possible to use several search parameters hereclassdatabase.update_entryParametertable:string, search_parameter:dict, update_parameterdict# Example Table Nametable_name="cars_table"# Example Search Parametersearch_parameter={"manufacture":"toyoat"}# Example Update Parametersearch_parameter={"manufacture":"toyota"}# Example Table creationdb.update_entry(table_name,search_parameter)# Example Table Nametable_name="cars_table"# Example Search Parametersearch_parameter={"manufacture":"toyoat","model":"Aygo X yalp",}# Example Update Parametersearch_parameter={"manufacture":"toyota""model":"Aygo X play",}# Example Search Operatorsearch_operator=["AND"]# Example Table creationdb.update_entry(table_name,search_parameter,search_operator)It's also possible to use multiple search and update parameter here