{"id":19293659,"url":"https://github.com/tursodatabase/libsql-client-py","last_synced_at":"2025-04-22T07:32:21.670Z","repository":{"id":145134073,"uuid":"613781236","full_name":"tursodatabase/libsql-client-py","owner":"tursodatabase","description":"Python SDK for libSQL","archived":false,"fork":false,"pushed_at":"2024-05-03T09:30:16.000Z","size":181,"stargazers_count":74,"open_issues_count":15,"forks_count":10,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-01T20:51:33.177Z","etag":null,"topics":["client","libsql","python","sqlite"],"latest_commit_sha":null,"homepage":"https://libsql.org/libsql-client-py/","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/tursodatabase.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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-03-14T09:02:52.000Z","updated_at":"2025-03-28T20:53:06.000Z","dependencies_parsed_at":"2024-11-09T22:35:47.484Z","dependency_job_id":null,"html_url":"https://github.com/tursodatabase/libsql-client-py","commit_stats":null,"previous_names":["libsql/libsql-client-py"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tursodatabase%2Flibsql-client-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tursodatabase%2Flibsql-client-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tursodatabase%2Flibsql-client-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tursodatabase%2Flibsql-client-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tursodatabase","download_url":"https://codeload.github.com/tursodatabase/libsql-client-py/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250195054,"owners_count":21390230,"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":["client","libsql","python","sqlite"],"created_at":"2024-11-09T22:35:41.775Z","updated_at":"2025-04-22T07:32:21.377Z","avatar_url":"https://github.com/tursodatabase.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Python SDK for libSQL\n\n**[API reference][reference] | [Github][github] | [PyPI][pypi]**\n\n[reference]: https://libsql.org/libsql-client-py/reference.html\n[github]: https://github.com/libsql/libsql-client-py\n[pypi]: https://pypi.org/project/libsql-client/\n\nThis is the source repository of the Python SDK for libSQL. You can either connect to a local SQLite database or to a remote libSQL server ([sqld][sqld]).\n\n\u003e **_NOTE:_**  If you want to use libSQL with SQLAlchemy, you should check out the [libSQL dialect](https://github.com/libsql/sqlalchemy-libsql).\n\n[sqld]: https://github.com/libsql/sqld\n\n## Installation\n\n```\npip install libsql-client\n```\n\n## Getting Started\n\nConnecting to a local SQLite database:\n\n```python\nimport asyncio\nimport libsql_client\n\nasync def main():\n    url = \"file:local.db\"\n    async with libsql_client.create_client(url) as client:\n        result_set = await client.execute(\"SELECT * from users\")\n        print(len(result_set.rows), \"rows\")\n        for row in result_set.rows:\n            print(row)\n\nasyncio.run(main())\n```\n\nTo connect to a remote libSQL server ([sqld][sqld]), just change the URL:\n\n```python\nurl = \"ws://localhost:8080\"\n```\n\n## Supported URLs\n\nThe client can connect to the database using different methods depending on the scheme (protocol) of the passed URL:\n\n* `file:` connects to a local SQLite database (using the builtin `sqlite3` package)\n  * `file:/absolute/path` or `file:///absolute/path` is an absolute path on local filesystem\n  * `file:relative/path` is a relative path on local filesystem\n  * (`file://path` is not a valid URL)\n* `ws:` or `wss:` connect to sqld using WebSockets (the Hrana protocol).\n* `http:` or `https:` connect to sqld using HTTP. The `transaction()` API is not available in this case.\n* `libsql:` is equivalent to `wss:`.\n\n## Synchronous API\n\nThis package also provides a synchronous version of the client, which can be created by calling `create_client_sync()`. It supports the same methods as the default `asyncio` client, except that they block the calling thread:\n\n```python\nimport libsql_client\n\nurl = \"file:local.db\"\nwith libsql_client.create_client_sync(url) as client:\n    result_set = client.execute(\"SELECT * from users\")\n    print(len(result_set.rows), \"rows\")\n    for row in result_set.rows:\n        print(row)\n```\n\nThe synchronous client is just a thin wrapper around the asynchronous client, but it runs the event loop in a background thread.\n\n## Contributing to this package\n\nFirst, please install Python and [Poetry][poetry]. To install all dependencies for local development to a\nvirtual environment, run:\n\n[poetry]: https://python-poetry.org/\n\n```\npoetry install --with dev\n```\n\nTo run the tests, use:\n\n```\npoetry run pytest\n```\n\nTo check types with MyPy, use:\n\n```\npoetry run mypy\n```\n\n## License\n\nThis project is licensed under the MIT license.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in `libsql-client` by you, shall be licensed as MIT, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftursodatabase%2Flibsql-client-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftursodatabase%2Flibsql-client-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftursodatabase%2Flibsql-client-py/lists"}