File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -330,8 +330,24 @@ pub struct Cursor {
330330// SAFETY: The libsql crate guarantees that `Connection` is thread-safe.
331331unsafe impl Send for Cursor { }
332332
333+ impl Drop for Cursor {
334+ fn drop ( & mut self ) {
335+ self . stmt . replace ( None ) ;
336+ self . rows . replace ( None ) ;
337+ }
338+ }
339+
333340#[ pymethods]
334341impl Cursor {
342+ fn close ( self_ : PyRef < ' _ , Self > ) -> PyResult < ( ) > {
343+ rt ( ) . block_on ( async {
344+ let cursor: & Cursor = & self_;
345+ cursor. stmt . replace ( None ) ;
346+ cursor. rows . replace ( None ) ;
347+ } ) ;
348+ Ok ( ( ) )
349+ }
350+
335351 fn execute < ' a > (
336352 self_ : PyRef < ' a , Self > ,
337353 sql : String ,
@@ -474,11 +490,6 @@ impl Cursor {
474490 fn rowcount ( self_ : PyRef < ' _ , Self > ) -> PyResult < i64 > {
475491 Ok ( * self_. rowcount . borrow ( ) )
476492 }
477-
478- fn close ( _self : PyRef < ' _ , Self > ) -> PyResult < ( ) > {
479- // TODO
480- Ok ( ( ) )
481- }
482493}
483494
484495async fn begin_transaction ( conn : & libsql_core:: Connection ) -> PyResult < ( ) > {
You can’t perform that action at this time.
0 commit comments