File tree 2 files changed +29
-0
lines changed 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,18 @@ con = libsql.connect("hello.db")
49
49
cur = con.cursor()
50
50
```
51
51
52
+ #### Remote database
53
+
54
+ ``` python
55
+ import libsql_experimental as libsql
56
+
57
+ url = os.getenv(" LIBSQL_URL" )
58
+ auth_token = os.getenv(" LIBSQL_AUTH_TOKEN" )
59
+
60
+ con = libsql.connect(database = url, auth_token = auth_token)
61
+ cur = con.cursor()
62
+ ```
63
+
52
64
#### Embedded replica
53
65
54
66
``` python
Original file line number Diff line number Diff line change
1
+ """
2
+ A short example showing how to connect to a remote libsql or Turso database
3
+
4
+ Set the LIBSQL_URL and LIBSQL_AUTH_TOKEN environment variables to point to a database.
5
+ """
6
+ import os
7
+
8
+ import libsql_experimental as libsql
9
+
10
+ print (F"connecting to { os .getenv ('LIBSQL_URL' )} " )
11
+ conn = libsql .connect (database = os .getenv ('LIBSQL_URL' ),
12
+ auth_token = os .getenv ("LIBSQL_AUTH_TOKEN" ))
13
+ conn .execute ("CREATE TABLE IF NOT EXISTS users (id INTEGER);" )
14
+ conn .execute ("INSERT INTO users(id) VALUES (10);" )
15
+ conn .commit ()
16
+
17
+ print (conn .execute ("select * from users" ).fetchall ())
You can’t perform that action at this time.
0 commit comments