{"id":18982307,"url":"https://github.com/profusion/django_libsql","last_synced_at":"2025-09-06T01:32:11.124Z","repository":{"id":206248575,"uuid":"715713333","full_name":"profusion/django_libsql","owner":"profusion","description":null,"archived":false,"fork":false,"pushed_at":"2023-11-17T15:15:24.000Z","size":45,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-06T17:51:39.560Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/profusion.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":"2023-11-07T17:23:42.000Z","updated_at":"2024-09-28T14:12:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"1f0561ec-7c67-41cd-93a7-a674219232ce","html_url":"https://github.com/profusion/django_libsql","commit_stats":null,"previous_names":["profusion/django_libsql"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/profusion/django_libsql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/profusion%2Fdjango_libsql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/profusion%2Fdjango_libsql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/profusion%2Fdjango_libsql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/profusion%2Fdjango_libsql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/profusion","download_url":"https://codeload.github.com/profusion/django_libsql/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/profusion%2Fdjango_libsql/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273846956,"owners_count":25178629,"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","status":"online","status_checked_at":"2025-09-05T02:00:09.113Z","response_time":402,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-08T16:13:05.126Z","updated_at":"2025-09-06T01:32:10.762Z","avatar_url":"https://github.com/profusion.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# django_libsql\n\nlibSQL backend compatibility for django.\n\n# Pre-requisites\n\nYou must have a running instance of [sqld](https://github.com/libsql/sqld), which is the libSQL server mode. There are several supported options:\n\n- [Build and run an instance](https://github.com/libsql/sqld/blob/main/docs/BUILD-RUN.md) on your local machine.\n- Use an instance managed by [Turso](https://turso.tech/).\n- Use the [libSQL test server](https://github.com/libsql/hrana-test-server) implemented in python\n\n# Co-requisites\n\nThis custom backend requires django version 4.1.0 or higher and [libsql_client](https://pypi.org/project/libsql-client/)\n\n# Getting started\n\nIn your django project settings, if you're using the sqlite engine you'll find something like this\n\n``` python\nDATABASES = {\n    'default': {\n        'ENGINE': 'django.db.backends.sqlite3',\n        'NAME': BASE_DIR / 'db.sqlite3',\n    }\n}\n```\n\nJust change the engine name to `django_libsql` and your database name to the appropriate Turso URL\n\n``` python\nDATABASES = {\n    'default': {\n        'ENGINE': 'django_libsql',\n        'NAME': 'libsql://you-database-hostname?authToken=your-auth-token'\n    }\n}\n```\n\nOr, if you're running a local instance of sqld, the name will be just `libsql://127.0.0.1:PORT`.\n\n# Known issues\n\nThe implementation of the standard sqlite backend for django uses the\n[create_function api](https://docs.python.org/3/library/sqlite3.html#sqlite3.Connection.create_function)\nin order to define some custom functionalities of the framework.\nWe currently do not support this feature in the [libsql_client](https://pypi.org/project/libsql-client/), which means we don't support the functions\nlisted [here](https://github.com/django/django/blob/8b1acc0440418ac8f45ba48e2dfcf5126c83341b/django/db/backends/sqlite3/_functions.py#L39-L102).\n\nYou can see which functions are registered to a given database by querying the `pragma_function_list` table. When running django with the standard\nsqlite backend, the functions mentioned above will be registered, whereas with `django_libsql`, they won't.\n\nMore concretely, here are some of the things that will not work in the current version:\n\nLet the model `Product` be defined by:\n\n``` python\n    class Product(models.Model):\n        made_at = models.DateTimeField()\n        valid_until = models.DateTimeField()\n```\n\nThen\n\n``` python\n    \u003e\u003e\u003e from django.db.models import F\n    \u003e\u003e\u003e Product.objects.annotate(date_diff=F(\"valid_until\") - F(\"made_at\"))\n```\nwill raise:\n`django.db.utils.OperationalError: SQL_INPUT_ERROR: SQL input error: no such function: django_timestamp_diff (at offset 87)`\n\nLet the model `ShcoolClass` be defined by:\n\n``` python\n    class SchoolClass(models.Model):\n        year = models.PositiveIntegerField()\n        day = models.CharField(max_length=9, blank=True)\n        last_updated = models.DateTimeField()\n\n        objects = SchoolClassManager()\n```\n\nThen\n\n``` python\n    \u003e\u003e\u003e import datetime\n    \u003e\u003e\u003e updated = datetime.datetime(2023, 2, 20)\n    \u003e\u003e\u003e SchoolClass.objects.create(year=2022, last_updated=updated)\n    \u003cSchoolClass: SchoolClass object (3)\u003e\n    \u003e\u003e\u003e years = SchoolClass.objects.dates(\"last_updated\", \"year\")\n    \u003e\u003e\u003e years\n```\n\nwill raise:\n`django.db.utils.OperationalError: SQL_INPUT_ERROR: SQL input error: no such function: django_date_trunc (at offset 16)`\n\nThese are some examples, but in general, any framework feature that uses the functions\nlisted\n[here](https://github.com/django/django/blob/8b1acc0440418ac8f45ba48e2dfcf5126c83341b/django/db/backends/sqlite3/_functions.py#L39-L102)\nwill not work for the time being.\n\n\n# License\n\ndjango_libsql is distributed under the [MIT license](https://opensource.org/licenses/MIT).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprofusion%2Fdjango_libsql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprofusion%2Fdjango_libsql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprofusion%2Fdjango_libsql/lists"}