Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.

Commit 194f616

Browse files
CodingDougbarbieri
authored andcommitted
Improve README
1 parent c9451fe commit 194f616

File tree

1 file changed

+35
-13
lines changed

1 file changed

+35
-13
lines changed

README.rst

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,58 @@
11
sqlalchemy-libsql
22
=================
33

4-
A `LibSQL <https://libsql.org/>`_ dialect for SQLAlchemy.
5-
6-
This dialect requires SQLAlchemy 2.0 or later.
4+
A `libSQL <https://libsql.org/>`_ dialect for `SQLAlchemy <https://www.sqlalchemy.org/>`_.
75

86

97
Pre-requisites
108
--------------
119

12-
- Running instance of https://github.com/libsql/sqld. You can easily get one at https://turso.tech/
13-
- Alternatively a https://github.com/libsql/hrana-test-server, a pure-python implementation
10+
You must have a running instance of `sqld <https://github.com/libsql/sqld>`_,
11+
which is the libSQL server mode. There are several supported options:
12+
13+
- `Build and run an instance
14+
<https://github.com/libsql/sqld/blob/main/docs/BUILD-RUN.md>`_ on your local
15+
machine.
16+
- Use an instance managed by `Turso <https://turso.tech/>`_.
17+
- Use the `libSQL test server <https://github.com/libsql/hrana-test-server>`_
18+
implemented in python
1419

1520
Co-requisites
1621
-------------
1722

18-
This dialect requires SQLAlchemy and libsql_client. They are specified as requirements so ``pip``
19-
will install them if they are not already in place. To install, just::
23+
This dialect requires the python packages `SQLAlchemy
24+
<https://pypi.org/project/SQLAlchemy/>`__ (version 2.0 or later) and
25+
`libsql_client <https://pypi.org/project/libsql-client/>`_. They are specified
26+
as requirements so ``pip`` will install them if they are not already in place.
27+
To install, just::
2028

2129
pip install sqlalchemy-libsql
2230

2331
Getting Started
2432
---------------
2533

26-
Create an URL that points to your libsql database.
27-
Then, in your Python app, you can connect to the database via::
34+
You must construct a special URL that SQLAlchemy can use to locate your
35+
database. This will be different than the usual HTTP or websocket URLs that you
36+
normally use with the libSQL client SDKs.
2837

29-
from sqlalchemy import create_engine
30-
engine = create_engine("sqlite+libsql://your-db.your-server.com?authToken=JWT_HERE&secure=true")
38+
If you are running an instance of sqld on your own machine, normally listening
39+
at 127.0.0.1 port 8080, the SQLAlchemy URL looks like this::
40+
41+
sqlite+libsql://127.0.0.1:8080
42+
43+
If your sqld instance is configured to use SSL with some hostname, and requires
44+
authentication with a database token (including Turso databases), you must
45+
provide two additional configurations in the query string of the URL::
3146

32-
Note that ``secure=true`` query/search parameter will force the usage of
33-
secure WebSockets (``wss://``) to connect to the remote server.
47+
sqlite+libsql://your-database-hostname/?authToken=your-auth-token&secure=true
48+
49+
``your-database-hostname`` and ``your-auth-token`` above are unique to your
50+
database. ``secure=true`` specifies the use of SSL.
51+
52+
You can then pass this URL to SQLAlchemy::
53+
54+
from sqlalchemy import create_engine
55+
engine = create_engine(url)
3456

3557
Development
3658
-----------

0 commit comments

Comments
 (0)