{"id":25601213,"url":"https://github.com/xeferis/simple_database","last_synced_at":"2026-04-29T13:33:19.956Z","repository":{"id":235478520,"uuid":"790752328","full_name":"Xeferis/Simple_Database","owner":"Xeferis","description":"A Module wich can be used to generate, establish connection and use SQLite Databases in Python with minimal effort.","archived":false,"fork":false,"pushed_at":"2024-07-24T08:47:50.000Z","size":136,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-11T18:15:54.699Z","etag":null,"topics":["database","database-management","minimal-efforts","module","packet","python","simple","simplify","slim","sqlite3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Xeferis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-23T13:14:57.000Z","updated_at":"2024-07-24T08:46:51.000Z","dependencies_parsed_at":"2024-04-23T15:28:22.658Z","dependency_job_id":"a68d734b-6147-423d-9b52-73775cd287ea","html_url":"https://github.com/Xeferis/Simple_Database","commit_stats":null,"previous_names":["xeferis/sqlite_helper","xeferis/simple_database"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/Xeferis/Simple_Database","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xeferis%2FSimple_Database","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xeferis%2FSimple_Database/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xeferis%2FSimple_Database/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xeferis%2FSimple_Database/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Xeferis","download_url":"https://codeload.github.com/Xeferis/Simple_Database/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xeferis%2FSimple_Database/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32427578,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T12:24:25.982Z","status":"ssl_error","status_checked_at":"2026-04-29T12:24:24.439Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","database-management","minimal-efforts","module","packet","python","simple","simplify","slim","sqlite3"],"created_at":"2025-02-21T15:53:04.737Z","updated_at":"2026-04-29T13:33:19.940Z","avatar_url":"https://github.com/Xeferis.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple_Database  \n\n[Report Bugs](https://github.com/Xeferis/Simple_Database/issues/new/choose)  \n\nA Module wich can be used to generate, establish connection and use SQLite Databases in Python with minimal effort.\n\nAlpha state - see [Milestones](https://github.com/Xeferis/Simple_Database/milestones) for planned developments.\n\n# Documentation\n\nIt's also found in the [Wiki](https://github.com/Xeferis/Simple_Database/wiki).\n\n### Collection of Classes and Functions\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch2\u003eclass: establish_db()\u003c/h2\u003e\u003c/summary\u003e  \n\nParameters:  \n`db_name: str`  \n\nTo initialize a Database you have to give it a name or, if a database already exists, provide a name.  \n🛑 Normally not used standalone, it inherits to the other classes! 🛑\n\n_Excample:_  \n```\ndb = establish_db(\"expml\")  \n``` \n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch3\u003eFunctions\u003c/h3\u003e\u003c/summary\u003e  \n\n* ### `close()`  \n\n\u003c/details\u003e\n\nJust use the \"close\" tag on the database clase to close this connection  \n\n_Excample:_\n```\ndb = establish_db(\"expml\")\n#some code  \ndb.close()  \n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch2\u003eclass: generate_db()\u003c/h2\u003e\u003c/summary\u003e  \n\nParameters:  \n`db_name: str`\n\nThis class is used to build up a database. Fill it with tables or delete tables.\nIt inherits from \"establish_db\" so it also needs the database name to generate a database or open a connection.\n\n_Excample:_\n```\ndb = generate_db(\"expml\")\n```\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch3\u003eFunctions\u003c/h3\u003e\u003c/summary\u003e  \n\n* ### `add_table()`  \nParameters:  \n`tbl_name: str`  \n`col: dict`  \n\nReturn:  \n`bool`   \n\n\nAdding tables to your database by giving it a name and the column information. The dict for the column information ist structured like this:  \n```  \n\"col_name\": {\n                \"primarykey\": bool,\n                \"autoincrement\": bool,\n                \"type\": DATATYPEasSTRING,\n                \"mandatory\": bool,\n                \"foreignkey\": (\n                    bool,\n                    {\n                        \"table\": REFERENCE_TABLENAMEasSTRING,\n                        \"column\": REFERENCE_COLUMNNAMEasSTRING\n                    }\n                )\n            },\n```\n  \n_Excample:_\n```\ndb = generate_db(\"expml\")\ndb.add_table(\n        \"Test\", {\n            \"ID\": {\n                \"primarykey\": True,\n                \"autoincrement\": True,\n                \"type\": \"INTEGER\",\n                \"mandatory\": False,\n                \"foreignkey\": (\n                    False,\n                    {\n                        \"table\": \"\",\n                        \"column\": \"\"\n                    }\n                )\n            },\n            \"Title\": {\n                \"primarykey\": False,\n                \"autoincrement\": False,\n                \"type\": \"CHAR(20)\",\n                \"mandatory\": True,\n                \"foreignkey\": (\n                    False,\n                    {\n                        \"table\": \"\",\n                        \"column\": \"\"\n                    }\n                )\n            },\n            \"Name\": {\n                \"primarykey\": False,\n                \"autoincrement\": False,\n                \"type\": \"TEXT\",\n                \"mandatory\": True,\n                \"foreignkey\": (\n                    False,\n                    {\n                        \"table\": \"\",\n                        \"column\": \"\"\n                    }\n                )\n            },\n            \"Age\": {\n                \"primarykey\": False,\n                \"autoincrement\": False,\n                \"type\": \"INTEGER\",\n                \"mandatory\": False,\n                \"foreignkey\": (\n                    False,\n                    {\n                        \"table\": \"\",\n                        \"column\": \"\"\n                    }\n                )\n            }\n        }\n    )\ndb.close()\n```\n\n\n* ### `remove_table()`\n \nParameters:  \n`tbl_name: str`   \n\nReturn:  \n`bool`   \n\nThis will remove a table of the database by its given name. \n\nIMPORTANT: It will delete the table no matter what! Watch out if it has foreign relations\n\nWill return true if deletion was successful\n\n_Excample:_\n```\ndb = generate_db(\"expml\")\ndb.remove_table(tbl_name: str)\ndb.close()\n```\n\n\u003c/details\u003e\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch2\u003eclass: operate_db()\u003c/h2\u003e\u003c/summary\u003e\n\nParameters:  \n`db_name: str`\n\nThis class is used to operate a database. You can add, del, get and search content in a database\n\n_Excample:_\n```\ndb = operate_db(\"expml\")\n```\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch3\u003eFunctions\u003c/h3\u003e\u003c/summary\u003e  \n\n* ### `add_content()`\n \nParameters:  \n`tbl_name: str` \n`cntnt: dict | list[dict]`  \n`with_foreign_key: bool | tuple -\u003e defaults to false`   \n   \nYou can add single lines of data or add a whole batch of data as a list. With the foreign key parameter you can give it a table and the key that should be added. It tests if the key exists in the destination table. \n\n_Excample 1 (Single Data):_\n```\n# DB is already initialized and table \"Users\" is added\ndata1 = {'Name': 'John', 'Age': 30}\ndb.add_content('Users', data1)\n```\n\n_Excample 2 (Batch Data):_\n```\n# DB is already initialized and table \"Users\" is added\ndata2 = [{'Name': 'John', 'Age': 30},\n{'Name': 'Sarah', 'Age': 27},\n{'Name': 'Genji', 'Age': 35}]\ndb.add_content('Users', data1)\n```\n\n_Excample 3 (Foreign key):_\n```\n# DB is already initialized and table \"Users\" \u0026 \"Department\" are added.\n# The Department ID 423 is also already added\ndata3 = {'Name': 'John', 'Age': 30}\ndb.add_content('Users', data1, (\"Department\" {\"DID\": 423}))\ndb.close()\n```\n\n* ### `update_content()`\n \nParameters:  \n`tbl_name: str` \n`search: dict`\n`cntnt: dict | dict`  \n \n   \nYou can update datasets by searching for it and then fill the new information.\n\n_Excample 1:_\n```\n# DB is already initialized and table \"Users\" is added.\n# The database has a dataset with the id 456 and a current name of \"bob\"\ntbl = \"users\"\ndataset2update = {\"id\": 456}\ndata2update = {\"name\": \"john\"}\ndb.update_content(tbl, dataset2update, data2update)\n# Now the dataset with the id 465 should have the name \"john\" and not \"bob\" anymore\n```\n\n* ### `del_content()`\n \nParameters:  \n`tbl_name: str` \n`search: dict`\n\nYou can remove content with this function by searching for attributes. All datasets that will be found are going to be deleted.\n\nIMPORTANT: There is no confirmation. If it finds something it deletes it.\n   \n\n_Excample:_\n```\n# DB is already initialized and table \"Users\" is added.\n# The Dataset for the name \"Bob\" is added.\ndata2delete = {'name': 'Bob'}\ndb.del_content('Users', data2delete)\n# Now all Data where the name was \"Bob\" has been deleted!\n```\n\n* ### `get_content()`\n \nParameters:  \n`tbl_name: str` \n\nReturns:  \n`list`\n   \n\nWith this you get all the data from a specific table.\n\n_Excample:_\n```\n# DB is already initialized and table \"Users\" is added.\n# The Database is filled with data\ndata = db.get_content('Users')\nprint(data)\n# Now all Data will be printed\n```\n\n* ### `search_table()`\n \nParameters:  \n`tbl_name: str` \n`search: dict`\n\nReturns:  \n`list`\n   \nYou can search for specific datasets and all the found data will be returned as list\n\n_Excample:_\n```\n# DB is already initialized and table \"Users\" is added.\n# The Database is filled with data\ndata2search = {'name': 'Bob'}\nfound_data = db.search_content('Users', data2search)\nprint(found_data)\n# Now all Datasets with the name \"Bob\" will be printed\n```\n\n\u003c/details\u003e\n\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxeferis%2Fsimple_database","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxeferis%2Fsimple_database","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxeferis%2Fsimple_database/lists"}