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:
parent
bb2223c8b0
commit
6a567a0dd6
@ -1,4 +1,4 @@
|
|||||||
## Description:
|
## Description
|
||||||
|
|
||||||
`sqlite` is a thin wrapper for [the SQLite library](https://sqlite.org/), which in turn is
|
`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,
|
"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)
|
- Download the source zip from [SQLite Downloads](https://sqlite.org/download.html)
|
||||||
- Create a new `sqlite` subfolder inside `v/thirdparty`
|
- Create a new `sqlite` subfolder inside `v/thirdparty`
|
||||||
- Extract the zip into that folder
|
- 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;')
|
||||||
|
```
|
@ -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
|
// In case you don't expect any result, but still want an error code
|
||||||
// e.g. INSERT INTO ... VALUES (...)
|
// e.g. INSERT INTO ... VALUES (...)
|
||||||
pub fn (db DB) exec_none(query string) int {
|
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
|
return code
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user