Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit ae5a000

Browse files
committed
common: No need to prepare the SQLite statement before execution
1 parent 52ecc26 commit ae5a000

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

common/sqlite.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ func ReadSQLiteDBCols(sdb *sqlite.Conn, dbTable, sortCol, sortDir string, ignore
786786
// ReadSQLiteDBCSV is a specialised variation of the ReadSQLiteDB() function, just for our CSV exporting code. It may
787787
// be merged with that in future.
788788
func ReadSQLiteDBCSV(sdb *sqlite.Conn, dbTable string) ([][]string, error) {
789-
// Retrieve all of the data from the selected database table
789+
// Retrieve all the data from the selected database table
790790
stmt, err := sdb.Prepare(`SELECT * FROM "` + dbTable + `"`)
791791
if err != nil {
792792
log.Printf("Error when preparing statement for database: %s\n", err)
@@ -965,18 +965,8 @@ func SQLiteExecuteQueryLive(baseDir, dbOwner, dbName, loggedInUser, query string
965965
// TODO: Probably add in the before and after logging info at some point (as per query function),
966966
// so we can analyse query execution times, memory use, etc
967967

968-
// Prepare the statement
969-
// FIXME: Do we need to do this prepare step? Am suspecting "no", as we don't (yet) have a way to
970-
// batch call the matching stmt.Exec() below. Not remembering what else it might benefit though.
971-
var stmt *sqlite.Stmt
972-
stmt, err = sdb.Prepare(query)
973-
if err != nil {
974-
return
975-
}
976-
defer stmt.Finalize()
977-
978968
// Execute the statement
979-
rowsChanged, err = stmt.ExecDml()
969+
rowsChanged, err = sdb.ExecDml(query)
980970
if err != nil {
981971
log.Printf("Error when executing query by '%s' for LIVE database (%s/%s): '%s'\n",
982972
SanitiseLogString(loggedInUser), SanitiseLogString(dbOwner), SanitiseLogString(dbName),

0 commit comments

Comments
 (0)