{"id":18853391,"url":"https://github.com/yusuf8ahmed/hawkdb","last_synced_at":"2025-04-14T10:24:19.087Z","repository":{"id":39761586,"uuid":"286025686","full_name":"yusuf8ahmed/HawkDB","owner":"yusuf8ahmed","description":"document database made with pure python3","archived":false,"fork":false,"pushed_at":"2022-07-05T21:55:57.000Z","size":112,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-27T23:41:46.994Z","etag":null,"topics":["complex-queries","database","datastructures","document-database","nosql","nosql-data-storage","nosql-database","pydb","python","python-library","python3","sql","sql-equivalent-statements"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yusuf8ahmed.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}},"created_at":"2020-08-08T10:56:07.000Z","updated_at":"2025-01-14T12:49:08.000Z","dependencies_parsed_at":"2022-07-09T15:47:11.517Z","dependency_job_id":null,"html_url":"https://github.com/yusuf8ahmed/HawkDB","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusuf8ahmed%2FHawkDB","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusuf8ahmed%2FHawkDB/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusuf8ahmed%2FHawkDB/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusuf8ahmed%2FHawkDB/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yusuf8ahmed","download_url":"https://codeload.github.com/yusuf8ahmed/HawkDB/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248860782,"owners_count":21173506,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["complex-queries","database","datastructures","document-database","nosql","nosql-data-storage","nosql-database","pydb","python","python-library","python3","sql","sql-equivalent-statements"],"created_at":"2024-11-08T03:44:13.439Z","updated_at":"2025-04-14T10:24:19.055Z","avatar_url":"https://github.com/yusuf8ahmed.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"image/logo.svg\"/\u003e\n\u003c/p\u003e \n\n### What is the HawkDB project\nWelcome! This project is a simple python3 library that uses .json files as a micro noSQL local database. While it is noSQL based database, it's functions are specifically designed with SQL statements in mind. HawkDB also enables you to write more complex and speed efficient queries.\n(Shown in [Complex User Queries](#Complex-Queries)).\n\nHawkDB was chosen as the final name for the project but the early name was PyDB\n\nCheck out [Disclaimer](#Disclaimer) \n\n## Table of Contents  \n- [Disclaimer](#Disclaimer)  \n- [SQL equivalent restructuring filters](#SQL-equivalent-restructuring-filter) \n- [SQL equivalent statements](#SQL-equivalent-statements) \n- [Complex User Queries](#Complex-Queries) \n\n## Disclaimer\n**This is a proof of concept**. I developed this project to challenge myself learn about the internals of databases, software design and object oriented programming.\n\n## Sample usage\n```python\nfrom Hawk import Pydb, Query\n\ndb = Pydb(connection=\"Users.json\", tablename=\"Users\")\nUser = Query(db)\n\nprint(db.length()) # int: number of columns\n\ndb.filter(User.name == \"Yusuf\")\n\nprint(db.all()) \n# List[Dict[str, Any]]: return columns where \n# that include -\u003e {\"name\": \"Yusuf\"}\n\ndb.filter(User.age != 16)\n\nprint(db.all()) \n# List[Dict[str, Any]]: return table where \n# that don't include -\u003e {\"age\": 16}\n\n```\n## SQL equivalent restructuring filter\n### ALL\nreturn result of query or whole table\n```python\ndb.filter(User.name == \"Yusuf\")\nprint(db.all()) \n# List[Dict[str, Any]]: return columns where \n# that include -\u003e {\"name\": 16} and limit to 5 return columns\n```\n### LIMIT\nreturn number of rows up to a specified limit\n```python\ndb.filter(User.age == 16)\nprint(db.limit(5)) \n# List[Dict[str, Any]]: return columns where \n# that include -\u003e {\"age\": 16} and limit to 5 return columns\n```\n### ASC\nNote: this is the natural order.\n```python\ndb.filter(User.name == \"Yusuf\")\nprint(db.asc()) \n# List[Dict[str, Any]]: return columns where \n# that include -\u003e {\"name\": \"Yusuf\"} \n```\n### DESC\nreverse of natural order\n```python\ndb.filter(User.name == \"Yusuf\")\n\nprint(db.desc()) \n# List[Dict[str, Any]]: return columns where \n# that include -\u003e {\"name\": \"Yusuf\"} and desc order\n```\n\n### TRIVAGO\nis a hotel\nyou think this is a joke but i am \nserious this is an actual method\n```python\ndb.trivago() \n```\n\n## SQL equivalent statements\n### SELECTALL\nEquivalent to SELECT * FROM _TABLENAME_;\u003cbr\u003e\nreturns a result table\n```python\ndb.selectall()\n```\n### SELECT\nEquivalent to SELECT column1, ... FROM _TABLENAME_;\u003cbr\u003e\nreturns columns the include specified keys\n```python\ndb.select([\"name\"])\n```\n### INSERT\nInsert new column into database \u003cbr\u003e\n```python\ndb.insert({\"name\": \"Yusuf\", \"age\": 16,\n        \"money\": None, \"Python\": True\n        \"Java\": False})\n```\n### UPDATE\nUPDATE table_name SET _column1_=_'value1'_, ... WHERE _column1_=_'value1'_; \u003cbr\u003e\nUpdate specific column(s) \n```python\ndb.update({\"seal\": True}, {\"name\": \"Yusuf\"})\n# add {\"seal\": True} where {\"name\": \"Yusuf\"}\n```\n### TRUNCATE\nTRUNCATE TABLE _TABLENAME_; \u003cbr\u003e\nThis command is **irreversible** and deletes all data inside a table, but not the table itself.\n```python\ndb.truncate()\n```\n### DELETE\nEquivalent to DELETE FROM _TABLENAME_ WHERE _KEY_=_'VALUE'_;\u003cbr\u003e\nDrop all columns with same key and value\n```python\ndb.delete({\"name\": \"Yusuf\"})\n```\n\n## Complex Queries\nthrough the use of these functions you will have the ability to do anything with the database:\n\n#### function release()\nReturn the whole table\n\nSample usage of **release()**\n```python\nfrom pydb import Pydb, Query\n\ndb = Pydb(connection=\"Users.json\", tablename=\"Users\")\n# No need for Query class\n\ntable = db.release() #return the whole database: List[Dict[str, Any]]\nquery = []\n\nfor col in table: \n    if col.get(\"age\") != None and col.get(\"age\") \u003e 20:\n        # get all Users that are 20+\n        query.append(col)\n\nprint(query)\n```\n\n#### function push()\nDelete current database and push given table into database.\n\nSample usage of **push()**\n```python\nfrom pydb import Pydb, Query\n\ndb = Pydb(connection=\"Users.json\", tablename=\"Users\")\n# No need for Query class\n\ntable = db.release() #return the whole database: List[Dict[str, Any]]\nquery_table = []\n\nfor col in table: \n    if col.get(\"age\") != None and col.get(\"age\") \u003e 20:\n        # get all Users that are 20+\n        query_table.append(col)\n\ndb.push(query_table)\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyusuf8ahmed%2Fhawkdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyusuf8ahmed%2Fhawkdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyusuf8ahmed%2Fhawkdb/lists"}