@@ -114,65 +114,3 @@ pub fn drop_or_create_foo_table(db: *mut sqlite3) -> bool {
114114
115115 true
116116}
117-
118- /// Helper to execute a SQL statement ignoring result rows.
119- /// Panics if execution fails.
120- ///
121- /// # Arguments
122- /// * `db` - Pointer to the open SQLite database connection.
123- /// * `sql` - The SQL statement to execute.
124- pub fn exec ( db : * mut sqlite3 , sql : & str ) {
125- let sql_c = std:: ffi:: CString :: new ( sql) . unwrap ( ) ;
126- let ret = unsafe {
127- sqlite3_exec (
128- db,
129- sql_c. as_ptr ( ) . cast ( ) ,
130- None ,
131- std:: ptr:: null_mut ( ) ,
132- std:: ptr:: null_mut ( ) ,
133- )
134- } ;
135- assert_eq ! ( ret, SQLITE_OK , "exec failed for: {}" , sql) ;
136- }
137-
138- /// Helper to prepare a SQL statement.
139- /// Returns the raw statement pointer.
140- /// Panics if preparation fails.
141- ///
142- /// # Arguments
143- /// * `db` - Pointer to the open SQLite database connection.
144- /// * `sql` - The SQL statement to prepare.
145- pub fn prepare ( db : * mut sqlite3 , sql : & str ) -> * mut sqlite3_stmt {
146- let sql_c = std:: ffi:: CString :: new ( sql) . unwrap ( ) ;
147- let mut stmt = std:: ptr:: null_mut ( ) ;
148- let ret = unsafe {
149- sqlite3_prepare_v2 (
150- db,
151- sql_c. as_ptr ( ) . cast ( ) ,
152- -1 ,
153- & mut stmt,
154- std:: ptr:: null_mut ( ) ,
155- )
156- } ;
157- assert_eq ! ( ret, SQLITE_OK , "prepare failed for: {}" , sql) ;
158- stmt
159- }
160-
161- /// Helper to read a text column from the current row of a statement.
162- /// Returns an empty string if NULL.
163- ///
164- /// # Arguments
165- /// * `stmt` - Pointer to the prepared statement.
166- /// * `col` - Zero-based index of the column to read.
167- pub fn text_from_col ( stmt : * mut sqlite3_stmt , col : i32 ) -> String {
168- unsafe {
169- let ptr = sqlite3_column_text ( stmt, col) ;
170- if ptr. is_null ( ) {
171- String :: new ( )
172- } else {
173- std:: ffi:: CStr :: from_ptr ( ptr. cast ( ) )
174- . to_string_lossy ( )
175- . into_owned ( )
176- }
177- }
178- }
0 commit comments