From 075cd29c14ef61a1322bfd4185034475d936d4ce Mon Sep 17 00:00:00 2001 From: kahsa Date: Thu, 6 Jan 2022 18:47:20 +0900 Subject: [PATCH] sqlite: add busy_timeout() (#13053) --- vlib/sqlite/sqlite.v | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/vlib/sqlite/sqlite.v b/vlib/sqlite/sqlite.v index f09262768b..8238dcca67 100644 --- a/vlib/sqlite/sqlite.v +++ b/vlib/sqlite/sqlite.v @@ -59,6 +59,8 @@ fn C.sqlite3_open(&char, &&C.sqlite3) int fn C.sqlite3_close(&C.sqlite3) int +fn C.sqlite3_busy_timeout(db &C.sqlite3, ms int) int + fn C.sqlite3_last_insert_rowid(&C.sqlite3) i64 // @@ -234,3 +236,8 @@ pub fn (db DB) exec_param(query string, param string) []Row { pub fn (db DB) create_table(table_name string, columns []string) { db.exec('create table if not exists $table_name (' + columns.join(',\n') + ')') } + +// Set a busy timeout in milliseconds https://www.sqlite.org/c3ref/busy_timeout.html +pub fn (db DB) busy_timeout(ms int) int { + return C.sqlite3_busy_timeout(db.conn, ms) +}