Closed vfat0 closed 4 years ago
Are there any plans to support this?
This is supported by doing the following: Use FSharp.Data.LiteralProviders with this type provider as follows:
open FSharp.Data.LiteralProviders
open FSharp.Data.Npgsql
let [<Literal>] GetData = TextFile<"./queries/script.sql">.Text
let [<Literal>] ConnectionString = TextFile<"CONNECTION_STRING.txt">.Text
type Database = NpgsqlConnection<ConnectionString>
let getDataFromDb() =
let query = Database .CreateCommand<GetData> (ConnectionString)
let data = query.Execute()
for row in data do
printfn "%A" row
Thank you this is certainly a good solution.
It would be great if the CommandProvider also worked with script files, e.g.
DB.CreateCommand<"Script.pgsql">(connString)
This would allow checking pgsql scripts for correctness at compile time, while maintaining syntax highlighting when viewing those script files.