1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

sqlite: improve exec_none behaviour (#14955)

This commit is contained in:
CC 2022-07-06 01:44:36 -06:00 committed by GitHub
parent bb2223c8b0
commit 6a567a0dd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View File

@ -1,4 +1,4 @@
## Description:
## Description
`sqlite` is a thin wrapper for [the SQLite library](https://sqlite.org/), which in turn is
"a C-language library that implements a small, fast, self-contained,
@ -23,3 +23,13 @@ library installed on your system.
- Download the source zip from [SQLite Downloads](https://sqlite.org/download.html)
- Create a new `sqlite` subfolder inside `v/thirdparty`
- Extract the zip into that folder
# Performance Tips
When performing a large amount of database calls (i.e. INSERTS), significant performance increase
can be obtained by issuing to sqlite the following pragma commands.
```
db.exec('pragma synchronous = off;')
db.exec('pragma journal_mode = MEMORY;')
```

View File

@ -222,7 +222,10 @@ pub fn (db DB) error_message(code int, query string) IError {
// In case you don't expect any result, but still want an error code
// e.g. INSERT INTO ... VALUES (...)
pub fn (db DB) exec_none(query string) int {
_, code := db.exec(query)
stmt := &C.sqlite3_stmt(0)
C.sqlite3_prepare_v2(db.conn, &char(query.str), query.len, &stmt, 0)
code := C.sqlite3_step(stmt)
C.sqlite3_finalize(stmt)
return code
}