SQLProvider
SQLProvider copied to clipboard
[Question] How to use Pragma with SQLITE?
When you use pragma statements with sqlite, you need to do it at the beginning of your connection. I am not sure how this is achievable with SqlProvider, any hints appreciated.
As SQLite doesn't support stored procedures and the features was already there, you can do pragma via them: https://fsprojects.github.io/SQLProvider/core/programmability.html
As in test-project:
let dc = sql.GetDataContext()
let pragmaSchemav = dc.Pragma.Get.Invoke("schema_version")
let res = pragmaSchemav.ResultSet |> Array.map(fun i -> i.ColumnValues |> Map.ofSeq)
let ver = (res |> Seq.head).["schema_version"] :?> Int64
let pragmaFk = dc.Pragma.GetOf.Invoke("foreign_key_list", "EmployeesTerritories")
let res = pragmaFk.ResultSet |> Array.map(fun i -> i.ColumnValues |> Map.ofSeq)
In particular I'd like to set busy_timeout per connection. How can I do it?
as in
PRAGMA busy_timeout
What happens if you do this: dc.Pragma.Get.Invoke("busy_timeout=300")
@Thorium, Invoke doesn't take any parameter with sqlite, not for get not for getof.
That's a bit weird because I took my code line from the test-project:
https://github.com/fsprojects/SQLProvider/blob/e1c768a701a0a6ec5ff47ddb74f6f1ef1ff7cbc2/tests/SqlProvider.Tests/QueryTests.fs#L2259