File tree Expand file tree Collapse file tree 2 files changed +12
-10
lines changed
Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -59,13 +59,11 @@ impl Backend for DuckdbQuackosm {
5959 async fn exec ( & mut self , sqls : Vec < String > ) -> Vec < String > {
6060 let mut sqls = sqls;
6161 let last_sql = sqls. pop ( ) . expect ( "No SQL queries to execute" ) ;
62- self . con
63- . execute_batch ( sqls. join ( "\n " ) . as_str ( ) )
64- . expect ( "Failed to execute SQL query" ) ;
65- let mut stmt = self
66- . con
67- . prepare ( & last_sql)
62+ let tx = self . con . transaction ( ) . expect ( "Failed to start transaction" ) ;
63+
64+ tx. execute_batch ( sqls. join ( "\n " ) . as_str ( ) )
6865 . expect ( "Failed to execute SQL query" ) ;
66+ let mut stmt = tx. prepare ( & last_sql) . expect ( "Failed to execute SQL query" ) ;
6967 stmt. query_map ( [ ] , |row| Ok ( row. get :: < usize , String > ( 0 ) . unwrap ( ) ) )
7068 . unwrap ( )
7169 . map ( |result| result. ok ( ) . unwrap ( ) )
Original file line number Diff line number Diff line change @@ -95,12 +95,16 @@ GROUP BY
9595 async fn exec ( & mut self , sqls : Vec < String > ) -> Vec < String > {
9696 let mut sqls = sqls;
9797 let last_sql = sqls. pop ( ) . expect ( "No SQL queries to execute" ) . to_string ( ) ;
98- self . con
99- . batch_execute ( sqls. join ( "\n " ) . as_str ( ) )
98+ let tx = self
99+ . con
100+ . transaction ( )
101+ . await
102+ . expect ( "Failed to start transaction" ) ;
103+
104+ tx. batch_execute ( sqls. join ( "\n " ) . as_str ( ) )
100105 . await
101106 . expect ( "Failed to execute SQL query" ) ;
102- self . con
103- . query ( & last_sql. to_string ( ) , & [ ] )
107+ tx. query ( & last_sql. to_string ( ) , & [ ] )
104108 . await
105109 . expect ( "Failed to execute SQL query" )
106110 . iter ( )
You can’t perform that action at this time.
0 commit comments