{"id":13629092,"url":"https://github.com/PythiaSocialTech/sirqle","last_synced_at":"2025-04-17T04:33:00.462Z","repository":{"id":62825344,"uuid":"562823285","full_name":"PythiaSocialTech/sirqle","owner":"PythiaSocialTech","description":"Surreal DB with Python wrapper","archived":false,"fork":false,"pushed_at":"2023-11-09T13:29:15.000Z","size":568,"stargazers_count":18,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-08T17:39:38.511Z","etag":null,"topics":["database","surrealdb","surrealdb-database","surrealdb-driver"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PythiaSocialTech.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2022-11-07T10:36:30.000Z","updated_at":"2025-04-06T17:40:13.000Z","dependencies_parsed_at":"2024-01-19T12:07:29.283Z","dependency_job_id":null,"html_url":"https://github.com/PythiaSocialTech/sirqle","commit_stats":{"total_commits":13,"total_committers":3,"mean_commits":4.333333333333333,"dds":0.3076923076923077,"last_synced_commit":"23d9b3bee26e645093618aea7ad2373a4e5d95a6"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PythiaSocialTech%2Fsirqle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PythiaSocialTech%2Fsirqle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PythiaSocialTech%2Fsirqle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PythiaSocialTech%2Fsirqle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PythiaSocialTech","download_url":"https://codeload.github.com/PythiaSocialTech/sirqle/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249316046,"owners_count":21249883,"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":["database","surrealdb","surrealdb-database","surrealdb-driver"],"created_at":"2024-08-01T22:01:02.483Z","updated_at":"2025-04-17T04:32:58.796Z","avatar_url":"https://github.com/PythiaSocialTech.png","language":"Python","funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"# Sirqle\n\n![Logo](assets/logo.png)\n\nSurreal DB with Python wrapper for [surrealdb.py](https://github.com/surrealdb/surrealdb.py) which makes it easy to write SurrealQL queries in Python.\n\nInstall with:\n\n```sh\npip install sirqle\n```\n\nUsage:\n\n```python\n\nfrom sirqle.query import Config, Query\n\nconfig = Config(\n        url = \"localhost:8000\",\n        namespace = \"test\",\n        database = \"test\",\n        username = \"test\",\n        password = \"test\",\n)\nmy_query = Query(config=config)\n\ntable_name = \"person\"\ncont = {\n    \"name\": \"Tobie\",\n    \"company\": \"SurrealDB\",\n    \"skills\": [\"Rust\", \"Go\", \"JavaScript\"],\n}\nmy_query.create(table_name).content(cont)\nresponse = await my_query.execute()\n\n# the result\n\nresponse = [{'company': 'SurrealDB', 'id': 'person:it2e579rij23zu0iswk4', 'name': 'Tobie', 'skills': ['Rust', 'Go', 'JavaScript']}]\n```\n\n## Config Module\n\nThe `Config` class is used to configure the connection the database. It uses the `SurrealHTTP` client and requires the following arguments depending on the desired method:\n\n\u003e 1. Manually enter the parameters\n\n- `url` : URL of the database\n- `namespace` : The namespace of the database\n- `database` : The name of the database\n- `username` : The access username\n- `password` : The access password\n\n\u003e 2. Pass a previous defined client\n\n- `client` : an `SurrealHTTP` client from `surrealdb.py`\n\n\u003e 3. Load the parameters from a file\n\n- `env_file`: the name of the env file. Defaults to `.db_conf`.\n\n## Query Module\n\nThe Query module aims to extend the standard SurrealQL and make it more Python friendly. Internally it constructs a SurrealQL string from method chaining and sends the query to the database.\n\n### Initialize the query\n\n```python\nquery = Query(config)\n```\n\n### Create examples\n\nCreate a new entry:\n\n```sql\nCREATE person CONTENT {\nname: 'Tobie',\ncompany: 'SurrealDB',\nskills: ['Rust', 'Go', 'JavaScript']\n};\n```\n\nbecomes\n\n```python\ntable_name = \"person\"\ncont = {\n    \"name\": \"Tobie\",\n    \"company\": \"SurrealDB\",\n    \"skills\": [\"Rust\", \"Go\", \"JavaScript\"],\n}\ncreate_query.create(table_name).content(cont)\n```\n\n### Insert example\n\n```sql\nINSERT INTO person (name, company, founded) VALUES ('John', 'SurrealDB', '2021-09-10');\n```\n\nbecomes\n\n```python\ntable_name = \"person (name, company, founded)\"\ndata = tuple([\"John\", \"SurrealDB\", \"2021-09-10\"])\ninsert_query.insert(table_name, values=data)\n```\n\n### Select example\n\n```sql\nSELECT * FROM person;\n```\n\nbecomes\n\n```python\nquery.select(\"*\").from_(\"person\")\n```\n\n\u003e **Execution**\n\nTo execute the query run `res = await query.execute()`, where `res` is the result of the query.\n\n### Custom query example\n\nIf you need something more complex than the basic operations, you can directly pass an SurrealQL query as a string:\n\n\u003e This query creates a temporary entry in the table `Topic` where we hash the values of `topic_label` and `topic_source`, returns the hash value and then delete the table.\n\n```python\ntable_name = \"Topic\"\ntopic_label = \"SurrealDB is awesome\"\ntopic_source = \"My personal knowledge\"\nmy_query.custom( f\"create {table_name} content\"\n                + f\" {{words: {topic_label}, source: {topic_source}}}\"\n                + f\" return crypto::md5(string::concat($this.words, $this.source));\"\n                + f\" delete from {table_name};\")\nresponse = await my_query.execute()\nresponse = {\"crypto::md5\": \"8f23a9630e18d525946740e5498798be\"}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPythiaSocialTech%2Fsirqle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPythiaSocialTech%2Fsirqle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPythiaSocialTech%2Fsirqle/lists"}