@@ -49,7 +49,7 @@ fn is_remote_path(path: &str) -> bool {
49
49
50
50
#[ pyfunction]
51
51
#[ cfg( not( Py_3_12 ) ) ]
52
- #[ pyo3( signature = ( database, timeout=5.0 , isolation_level="DEFERRED" . to_string( ) , _check_same_thread=true , _uri=false , sync_url=None , sync_interval=None , auth_token="" , encryption_key=None ) ) ]
52
+ #[ pyo3( signature = ( database, timeout=5.0 , isolation_level="DEFERRED" . to_string( ) , _check_same_thread=true , _uri=false , sync_url=None , sync_interval=None , offline= false , auth_token="" , encryption_key=None ) ) ]
53
53
fn connect (
54
54
py : Python < ' _ > ,
55
55
database : String ,
@@ -59,6 +59,7 @@ fn connect(
59
59
_uri : bool ,
60
60
sync_url : Option < String > ,
61
61
sync_interval : Option < f64 > ,
62
+ offline : bool ,
62
63
auth_token : & str ,
63
64
encryption_key : Option < String > ,
64
65
) -> PyResult < Connection > {
@@ -71,6 +72,7 @@ fn connect(
71
72
_uri,
72
73
sync_url,
73
74
sync_interval,
75
+ offline,
74
76
auth_token,
75
77
encryption_key,
76
78
) ?;
@@ -79,7 +81,7 @@ fn connect(
79
81
80
82
#[ pyfunction]
81
83
#[ cfg( Py_3_12 ) ]
82
- #[ pyo3( signature = ( database, timeout=5.0 , isolation_level="DEFERRED" . to_string( ) , _check_same_thread=true , _uri=false , sync_url=None , sync_interval=None , auth_token="" , encryption_key=None , autocommit = LEGACY_TRANSACTION_CONTROL ) ) ]
84
+ #[ pyo3( signature = ( database, timeout=5.0 , isolation_level="DEFERRED" . to_string( ) , _check_same_thread=true , _uri=false , sync_url=None , sync_interval=None , offline= false , auth_token="" , encryption_key=None , autocommit = LEGACY_TRANSACTION_CONTROL ) ) ]
83
85
fn connect (
84
86
py : Python < ' _ > ,
85
87
database : String ,
@@ -89,6 +91,7 @@ fn connect(
89
91
_uri : bool ,
90
92
sync_url : Option < String > ,
91
93
sync_interval : Option < f64 > ,
94
+ offline : bool ,
92
95
auth_token : & str ,
93
96
encryption_key : Option < String > ,
94
97
autocommit : i32 ,
@@ -102,6 +105,7 @@ fn connect(
102
105
_uri,
103
106
sync_url,
104
107
sync_interval,
108
+ offline,
105
109
auth_token,
106
110
encryption_key,
107
111
) ?;
@@ -126,6 +130,7 @@ fn _connect_core(
126
130
_uri : bool ,
127
131
sync_url : Option < String > ,
128
132
sync_interval : Option < f64 > ,
133
+ offline : bool ,
129
134
auth_token : & str ,
130
135
encryption_key : Option < String > ,
131
136
) -> PyResult < Connection > {
@@ -147,17 +152,20 @@ fn _connect_core(
147
152
match sync_url {
148
153
Some ( sync_url) => {
149
154
let sync_interval = sync_interval. map ( |i| std:: time:: Duration :: from_secs_f64 ( i) ) ;
150
- let mut builder = libsql_core:: Builder :: new_remote_replica (
155
+ let mut builder = libsql_core:: Builder :: new_synced_database (
151
156
database,
152
157
sync_url,
153
158
auth_token. to_string ( ) ,
154
159
) ;
155
- if let Some ( encryption_config) = encryption_config {
156
- builder = builder. encryption_config ( encryption_config) ;
160
+ if let Some ( _) = encryption_config {
161
+ return Err ( PyValueError :: new_err (
162
+ "encryption is not supported for synced databases" ,
163
+ ) ) ;
157
164
}
158
165
if let Some ( sync_interval) = sync_interval {
159
166
builder = builder. sync_interval ( sync_interval) ;
160
167
}
168
+ builder = builder. remote_writes ( !offline) ;
161
169
let fut = builder. build ( ) ;
162
170
tokio:: pin!( fut) ;
163
171
let result = rt. block_on ( check_signals ( py, fut) ) ;
0 commit comments