# SQL-Kit, sqlite and pragma commands

**URL:** <https://forums.swift.org/t/sql-kit-sqlite-and-pragma-commands/71570>\
**Category:** Vapor\
**Tags:** fluent, sqlite\
**Created:** [May 2, 2024, 8:33am UTC](https://forums.swift.org/t/sql-kit-sqlite-and-pragma-commands/71570 "2024-05-02T08:33:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![RussBaz](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/russbaz/32/30841_2.png) [@RussBaz](https://forums.swift.org/u/RussBaz)\
**Post date:** [May 2, 2024, 8:33am UTC](https://forums.swift.org/t/sql-kit-sqlite-and-pragma-commands/71570/1 "2024-05-02T08:33:28Z")

</div>

UPDATE: Scratch this topic because simply restarting fixed the issue. But does anyone know if the `SQLite-kit` support WAL2?

Hi everyone.

I am sending a `pragma` command to the SQLite after booting the server, but when I manually check the value I changed with an SQL IDE, I see the default value, not the updated one.

Here is the snipped of `configure` method where I do it:

```swift
// Fininsh the configuration
try app.boot()

// Configure sqlite db
guard let sql = app.db as? SQLDatabase else { fatalError("Could not open main sqlite db") }
try await sql.raw("PRAGMA journal_mode = wal2").run()

```

Does anyone know what I am doing wrong?

Thanks!

Edit: I am likely misunderstanding something because:

```swift
// register routes
try routes(app)

// Finish the configuration
try app.boot()

// Configure sqlite db
guard let sql = app.db as? SQLDatabase else { fatalError("Could not open main sqlite db") }

let a = (try await sql.raw("pragma synchronous").first(decoding: SynchronousStatus.self)?.synchronous).flatMap(String.init) ?? "--"
let b = try await sql.raw("pragma journal_mode").first(decoding: JournalModeStatus.self)?.journal_mode ?? "--"

try await sql.raw("pragma journal_mode = wal").run()
try await sql.raw("pragma synchronous = normal").run()

let c = (try await sql.raw("pragma synchronous").first(decoding: SynchronousStatus.self)?.synchronous).flatMap(String.init) ?? "--"
let d = try await sql.raw("pragma journal_mode").first(decoding: JournalModeStatus.self)?.journal_mode ?? "--"

app.logger.info("[Before] syncronous = \(a), journal_mode = \(b).")
app.logger.info("[After] syncronous = \(c), journal_mode = \(d).")

```

results in:

```swift
[DEBUG] pragma synchronous [] [database-id: sqlite] (SQLiteNIO/SQLiteConnection.swift:194)
[DEBUG] pragma journal_mode [] [database-id: sqlite] (SQLiteNIO/SQLiteConnection.swift:194)
[DEBUG] pragma journal_mode = wal [] [database-id: sqlite] (SQLiteNIO/SQLiteConnection.swift:194)
[DEBUG] pragma synchronous = normal [] [database-id: sqlite] (SQLiteNIO/SQLiteConnection.swift:194)
[DEBUG] pragma synchronous [] [database-id: sqlite] (SQLiteNIO/SQLiteConnection.swift:194)
[DEBUG] pragma journal_mode [] [database-id: sqlite] (SQLiteNIO/SQLiteConnection.swift:194)
[INFO] [Before] syncronous = 2, journal_mode = delete. (App/configure.swift:226)
[INFO] [After] syncronous = 1, journal_mode = wal. (App/configure.swift:227)

```

Edit2: After restarting my SQL editor, it started displaying the correct `pragma` values.
