@@ -49,7 +49,7 @@ fn is_remote_path(path: &str) -> bool {
4949
5050#[ pyfunction]
5151#[ 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 ) ) ]
5353fn connect (
5454 py : Python < ' _ > ,
5555 database : String ,
@@ -59,6 +59,7 @@ fn connect(
5959 _uri : bool ,
6060 sync_url : Option < String > ,
6161 sync_interval : Option < f64 > ,
62+ offline : bool ,
6263 auth_token : & str ,
6364 encryption_key : Option < String > ,
6465) -> PyResult < Connection > {
@@ -71,6 +72,7 @@ fn connect(
7172 _uri,
7273 sync_url,
7374 sync_interval,
75+ offline,
7476 auth_token,
7577 encryption_key,
7678 ) ?;
@@ -79,7 +81,7 @@ fn connect(
7981
8082#[ pyfunction]
8183#[ 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 ) ) ]
8385fn connect (
8486 py : Python < ' _ > ,
8587 database : String ,
@@ -89,6 +91,7 @@ fn connect(
8991 _uri : bool ,
9092 sync_url : Option < String > ,
9193 sync_interval : Option < f64 > ,
94+ offline : bool ,
9295 auth_token : & str ,
9396 encryption_key : Option < String > ,
9497 autocommit : i32 ,
@@ -102,6 +105,7 @@ fn connect(
102105 _uri,
103106 sync_url,
104107 sync_interval,
108+ offline,
105109 auth_token,
106110 encryption_key,
107111 ) ?;
@@ -126,6 +130,7 @@ fn _connect_core(
126130 _uri : bool ,
127131 sync_url : Option < String > ,
128132 sync_interval : Option < f64 > ,
133+ offline : bool ,
129134 auth_token : & str ,
130135 encryption_key : Option < String > ,
131136) -> PyResult < Connection > {
@@ -147,17 +152,20 @@ fn _connect_core(
147152 match sync_url {
148153 Some ( sync_url) => {
149154 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 (
151156 database,
152157 sync_url,
153158 auth_token. to_string ( ) ,
154159 ) ;
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+ ) ) ;
157164 }
158165 if let Some ( sync_interval) = sync_interval {
159166 builder = builder. sync_interval ( sync_interval) ;
160167 }
168+ builder = builder. remote_writes ( !offline) ;
161169 let fut = builder. build ( ) ;
162170 tokio:: pin!( fut) ;
163171 let result = rt. block_on ( check_signals ( py, fut) ) ;
0 commit comments