Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How to use Pragma with SQLITE? #794

Open
OnurGumus opened this issue May 25, 2023 · 6 comments
Open

[Question] How to use Pragma with SQLITE? #794

OnurGumus opened this issue May 25, 2023 · 6 comments

Comments

@OnurGumus
Copy link

OnurGumus commented May 25, 2023

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.

@OnurGumus OnurGumus changed the title [ [Question] How to use Pragma with SQLITE? May 25, 2023
@Thorium
Copy link
Member

Thorium commented May 25, 2023

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

@Thorium
Copy link
Member

Thorium commented May 25, 2023

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)

@OnurGumus
Copy link
Author

OnurGumus commented May 25, 2023

In particular I'd like to set busy_timeout per connection. How can I do it?
as in
PRAGMA busy_timeout

@Thorium
Copy link
Member

Thorium commented May 25, 2023

What happens if you do this: dc.Pragma.Get.Invoke("busy_timeout=300")

@OnurGumus
Copy link
Author

@Thorium, Invoke doesn't take any parameter with sqlite, not for get not for getof.

image

@Thorium
Copy link
Member

Thorium commented Jun 15, 2023

That's a bit weird because I took my code line from the test-project:

let pragmaSchemav = dc.Pragma.Get.Invoke("schema_version")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants