{"id":24122948,"url":"https://github.com/veepee-oss/vp.fsharp.sql.postgresql","last_synced_at":"2025-04-07T14:15:03.264Z","repository":{"id":53613096,"uuid":"315918354","full_name":"veepee-oss/Vp.FSharp.Sql.PostgreSql","owner":"veepee-oss","description":"F# Wrapper for PostgreSQL using Npgsql and Vp.FSharp.Sql","archived":false,"fork":false,"pushed_at":"2024-11-25T12:15:12.000Z","size":86,"stargazers_count":22,"open_issues_count":6,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-31T12:08:34.657Z","etag":null,"topics":["adonet","fsharp","npgsql","postgresql","sql"],"latest_commit_sha":null,"homepage":"https://github.com/veepee-oss/Vp.FSharp.Sql.PostgreSql","language":"F#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/veepee-oss.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-25T11:28:14.000Z","updated_at":"2024-11-25T12:15:16.000Z","dependencies_parsed_at":"2024-11-25T13:20:40.902Z","dependency_job_id":"5b336eb9-51a9-4caf-8aa7-cc4559f32dcf","html_url":"https://github.com/veepee-oss/Vp.FSharp.Sql.PostgreSql","commit_stats":{"total_commits":46,"total_committers":5,"mean_commits":9.2,"dds":"0.23913043478260865","last_synced_commit":"b508ec559520629d13064eb8e40b04f1dfd4f2e6"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veepee-oss%2FVp.FSharp.Sql.PostgreSql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veepee-oss%2FVp.FSharp.Sql.PostgreSql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veepee-oss%2FVp.FSharp.Sql.PostgreSql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veepee-oss%2FVp.FSharp.Sql.PostgreSql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/veepee-oss","download_url":"https://codeload.github.com/veepee-oss/Vp.FSharp.Sql.PostgreSql/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247666015,"owners_count":20975788,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adonet","fsharp","npgsql","postgresql","sql"],"created_at":"2025-01-11T12:33:47.567Z","updated_at":"2025-04-07T14:15:03.238Z","avatar_url":"https://github.com/veepee-oss.png","language":"F#","readme":"# Vp.FSharp.Sql.PostgreSql\r\n\r\nAn opinionated F# library to interact with PostgreSQL databases following [`Vp.FSharp.Sql`](https://github.com/veepee-oss/Vp.FSharp.Sql) principles and relying on [`Npsql`](https://www.nuget.org/packages/Npgsql).\r\n\r\n# ✨ Slagging Hype\r\n\r\nWe aim at following highly controversial practices to the best of our ability!\r\n\r\nStatus | Package\r\n------ | ----------------------\r\nOK     | [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-green.svg)](https://conventionalcommits.org)\r\nOK     | [![semver](https://img.shields.io/badge/semver-2.0.0-green)](https://semver.org/spec/v2.0.0.html)\r\nTBD    | [![keep a changelog](https://img.shields.io/badge/keep%20a%20changelog-1.0.0-red)](https://keepachangelog.com/en/1.0.0)\r\nTBD    | [![Semantic Release](https://img.shields.io/badge/Semantic%20Release-17.1.1-red)](https://semantic-release.gitbook.io/semantic-release)\r\n\r\n[Conventional Commits]: https://conventionalcommits.org\r\n[semver]: https://img.shields.io/badge/semver-2.0.0-blue\r\n[Semantic Release]: https://semantic-release.gitbook.io/semantic-release\r\n[keep a changelog]: https://keepachangelog.com/en/1.0.0\r\n\r\n# 📦 NuGet Package\r\n\r\nName                   | Version  | Command |\r\n----------------------- | -------- | ------- |\r\n`Vp.FSharp.Sql.PostgreSql` | [![NuGet Status](http://img.shields.io/nuget/v/Vp.FSharp.Sql.PostgreSql.svg)](https://www.nuget.org/packages/Vp.FSharp.Sql.PostgreSql) | `Install-Package Vp.FSharp.Sql.PostgreSql`\r\n\r\n# 📚 How to Use\r\n\r\n📝 Note: It's worth noting that the examples below illustrating functions running asynchronously do leverage `Async.RunSynchronously`. This is purely for the sake of reducing the nestedness that would happen if we were using `async` computation expressions instead.\r\n\r\n## 💿 Supported Database Values\r\n\r\nJust a little FYI:\r\n\r\n```fsharp\r\n/// Native PostgreSQL DB types.\r\n/// See https://www.npgsql.org/doc/types/basic.html\r\n/// and https://stackoverflow.com/a/845472/4636721\r\ntype PostgreSqlDbValue =\r\n    | Null\r\n    | Bit of bool\r\n    | Boolean of bool\r\n    | SmallInt of int16\r\n    | Integer of int32\r\n    | Oid of uint32\r\n    | Xid of uint32\r\n    | Cid of uint32\r\n    | BigInt of int64\r\n\r\n    | Real of single\r\n    | Double of double\r\n\r\n    | Money of decimal\r\n    | Numeric of decimal\r\n\r\n    | ByteA of uint8 array\r\n    | OidVector of uint32 array\r\n\r\n    | Uuid of Guid\r\n\r\n    | INet of IPAddress\r\n    | MacAddr of PhysicalAddress\r\n\r\n    | TsQuery of NpgsqlTsQuery\r\n    | TsVector of NpgsqlTsVector\r\n\r\n    | Point of NpgsqlPoint\r\n    | LSeg of NpgsqlLSeg\r\n    | Path of NpgsqlPath\r\n    | Polygon of NpgsqlPolygon\r\n    | Line of NpgsqlLine\r\n    | Circle of NpgsqlCircle\r\n    | Box of NpgsqlBox\r\n\r\n    | HStore of Dictionary\u003cstring, string\u003e\r\n\r\n    | Date of DateTime\r\n    | Interval of TimeSpan\r\n    | Time of DateTime\r\n    | TimeTz of DateTime\r\n    | Timestamp of DateTime\r\n    | TimestampTz of DateTimeOffset\r\n\r\n    | InternalChar of uint8\r\n\r\n    | Char of string\r\n    | VarChar of string\r\n\r\n    | Name of string\r\n    | CiText of string\r\n    | Text of string\r\n    | Xml of string\r\n    | Json of string\r\n    | Jsonb of string\r\n\r\n    /// Only if the relevant Npgsql mapping for the Enum has been set up beforehand.\r\n    /// See: https://www.npgsql.org/doc/types/enums_and_composites.html\r\n    | Enum of Enum\r\n    \r\n    | Custom of (NpgsqlDbType * obj)\r\n```\r\n\r\n## 🧱`PostgreSqlCommand`\r\n\r\nThe main module is here to help you build and execute (Postgre)SQL commands (i.e. `NpgsqlCommand` BTS).\r\n\r\n### 🏗️ Command Construction\r\n\r\nWe are obviously going to talk about how to build `NpgsqlCommand` definitions.\r\n\r\n📝 Note: the meaning of the word \"update\" below has to be put in a F# perspective, i.e. **immutable** update, as in the update returns a new updated and immutable instance.\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003etext\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Initialize a new command definition with the given text contained in the given string.\r\n\r\nExample:\r\n```fsharp\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nPostgreSqlCommand.text \"SELECT 42;\"\r\n|\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput:\r\n```txt\r\n42\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003etextFromList\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Initialize a new command definition with the given text spanning over several strings (ie. list).\r\n\r\nExample:\r\n```fsharp\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\n[ 0; 1; 1; 2; 3; 5; 8; 13; 21; 34; 55; ]\r\n|\u003e List.map (sprintf \"SELECT %d;\")\r\n|\u003e PostgreSqlCommand.textFromList\r\n|\u003e PostgreSqlCommand.queryList connection (fun _ _ read -\u003e read.Value\u003cint32\u003e 0)\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput:\r\n```txt\r\n[0; 1; 1; 2; 3; 5; 8; 13; 21; 34; 55]\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003enoLogger\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Update the command definition so that when executing the command, it doesn't use any logger.\r\n\u003e Be it the default one (Global, if any.) or a previously overriden one.\r\n\r\nExample:\r\n```fsharp\r\nPostgreSqlConfiguration.Logger (printfn \"Logging... %A\")\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nPostgreSqlCommand.text \"SELECT 42;\"\r\n|\u003e PostgreSqlCommand.noLogger\r\n|\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput:\r\n```txt\r\n42\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003eoverrideLogger\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Update the command definition so that when executing the command, it use the given overriding logger.\r\n\u003e instead of the default one, aka the Global logger, if any.\r\n\r\nExample:\r\n```fsharp\r\nPostgreSqlConfiguration.NoLogger ()\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nPostgreSqlCommand.text \"SELECT 42;\"\r\n|\u003e PostgreSqlCommand.overrideLogger (printfn \"Logging... %A\")\r\n|\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput:\r\n```fsharp\r\nLogging... ConnectionOpened Npgsql.NpgsqlConnection\r\nLogging... CommandPrepared Npgsql.NpgsqlCommand\r\nLogging... CommandExecuted (Npgsql.NpgsqlCommand, 00:00:00.0162810)\r\nLogging... ConnectionClosed (Npgsql.NpgsqlConnection, 00:00:00.1007513)\r\n42\r\n```\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003eparameters\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Update the command definition with the given parameters.\r\n\r\nExample:\r\n```fsharp\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nPostgreSqlCommand.text \"SELECT @a + @b;\"\r\n|\u003e PostgreSqlCommand.parameters [ (\"a\", Integer 42); (\"b\", Real 42.42f) ]\r\n|\u003e PostgreSqlCommand.executeScalar\u003cdouble\u003e connection\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput:\r\n```txt\r\n84.0\r\n```\r\n\r\nNote: in case you want to pass some types that aren't yet supported by the library,  \r\nyou can use the `Custom` DU case which allows you to pass whatever underlying `NpgsqlDbType` with the relevant `obj` value.\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003ecancellationToken\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Update the command definition with the given cancellation token.\r\n\r\nThis comes in handy when you need to interop with more traditional, C#-async, cancellation style.\r\n\r\nExample:\r\n```fsharp\r\ntry\r\n    use connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\n    PostgreSqlCommand.text \"SELECT 42;\"\r\n    |\u003e PostgreSqlCommand.cancellationToken (CancellationToken(true))\r\n    |\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n    |\u003e Async.RunSynchronously\r\n    |\u003e ignore\r\nwith\r\n | :? OperationCanceledException as e -\u003e\r\n     printfn \"The Command execution has been cancelled, reason: %A\" e.Message\r\n```\r\n\r\nOutput:\r\n```txt\r\nThe Command execution has been cancelled, reason: \"A task was canceled.\"\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003etimeout\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Update the command definition with the given timeout.\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003eprepare\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Update the command definition and sets whether the command should be prepared or not.\r\n\r\nAs per [MS Docs](https://docs.microsoft.com/en-us/sql/ado/referento%20have%20the%20provider%20save%20a%20prepared%20(or%20compiled)%20version%20of%20the%20query%20specified%20in%20the%20CommandText%20property%20before%20a%20Command%20object's%20first%20execution.%20This%20may%20slow%20a%20command's%20first%20execution,%20but%20once%20the%20provider%20compiles%20a%20command,%20the%20provider%20will%20use%20the%20compiled%20version%20of%20the%20command%20for%20any%20subsequent%20executions,%20which%20will%20result%20in%20improved%20performance.e/ado-api/prepared-property-ado):\r\n\r\n\u003e Use the `Prepared` property to have the provider save a prepared (or compiled) version\r\n\u003e of the query specified in the CommandText property before a Command object's first\r\n\u003e execution.\r\n\u003e\r\n\u003e This may slow a command's first execution, but once the provider compiles\r\n\u003e a command, the provider will use the compiled version of the command for any subsequent\r\n\u003e executions, which will result in improved performance.\r\n\r\nExample: TBD\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003etransaction\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Update the command definition and set whether the command should be wrapped in the given transaction.\r\n\r\nExample:\r\n```fsharp\r\nlet tableName = \"people\"\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nconnection.Open()\r\n\r\nuse transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted)\r\n\r\n// Create a table\r\nPostgreSqlCommand.text $\"CREATE TABLE {tableName} (id SERIAL PRIMARY KEY, name TEXT NOT NULL);\"\r\n|\u003e PostgreSqlCommand.transaction transaction\r\n|\u003e PostgreSqlCommand.executeNonQuery connection\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n\r\n// The table is created here\r\nPostgreSqlCommand.text $\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n|\u003e PostgreSqlCommand.transaction transaction\r\n|\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n\r\ntransaction.Rollback()\r\n\r\n// The table creation has been rollbacked\r\nPostgreSqlCommand.text $\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n|\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput:\r\n```txt\r\n-1\r\n1\r\n0\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n### ⚙ Command Execution\r\n\r\nWe are obviously going to talk about how to execute `NpgsqlCommand` definitions.\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003equeryAsyncSeq\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Execute the command and return the sets of rows as an `AsyncSeq` accordingly to the command definition.\r\n\u003e\r\n\u003e This function runs asynchronously.\r\n\r\nExample 1:\r\n```fsharp\r\ntype Row\u003c'T\u003e = { Set: int32; Record: int32; Data: 'T list }\r\n\r\nlet getCounterQuery n =\r\n    sprintf\r\n        \"\"\"\r\n        WITH RECURSIVE counter(value) AS (VALUES(1) UNION ALL SELECT value + 1 FROM counter WHERE value \u003c %d)\r\n        SELECT value FROM counter;\r\n        \"\"\" n\r\n\r\nlet readRow set record (read: SqlRecordReader\u003c_\u003e) =\r\n    { Set = set; Record = record; Data = List.init (read.Count) (read.Value\u003cint32\u003e) }\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\n[ 0; 1; 1; 2; 3; 5 ]\r\n|\u003e List.map getCounterQuery\r\n|\u003e PostgreSqlCommand.textFromList\r\n|\u003e PostgreSqlCommand.queryAsyncSeq connection readRow\r\n|\u003e AsyncSeq.toListSynchronously\r\n|\u003e List.iter (fun x -\u003e printfn \"Set = %A; Row = %A; Data = %A\" x.Set x.Record x.Data)\r\n```\r\n\r\nOutput 1:\r\n```txt\r\nSet = 0; Row = 0; Data = [1]\r\nSet = 1; Row = 0; Data = [1]\r\nSet = 2; Row = 0; Data = [1]\r\nSet = 3; Row = 0; Data = [1]\r\nSet = 3; Row = 1; Data = [2]\r\nSet = 4; Row = 0; Data = [1]\r\nSet = 4; Row = 1; Data = [2]\r\nSet = 4; Row = 2; Data = [3]\r\nSet = 5; Row = 0; Data = [1]\r\nSet = 5; Row = 1; Data = [2]\r\nSet = 5; Row = 2; Data = [3]\r\nSet = 5; Row = 3; Data = [4]\r\nSet = 5; Row = 4; Data = [5]\r\n```\r\n\r\nNotes 📝:\r\n- The output type must be consistent across all the result sets and records.\r\n- If you need different types you may want to either:\r\n  - Create DU with each type you want to output\r\n  - Use `querySetList2` or `querySetList3` ⬇️\r\n- The `read`er can also get the `Value` given a certain field name:\r\n\r\nExample 2:\r\n```fsharp\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\n[ 0; 1; 1; 2; 3; 5; 8; 13; 21; 34; 55; ]\r\n|\u003e List.map (sprintf \"SELECT %d AS cola;\")\r\n|\u003e PostgreSqlCommand.textFromList\r\n|\u003e PostgreSqlCommand.queryList connection (fun _ _ read -\u003e read.Value\u003cint32\u003e \"cola\")\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput 2:\r\n```txt\r\n[0; 1; 1; 2; 3; 5; 8; 13; 21; 34; 55]\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003equerySeqSync\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Execute the command and return the sets of rows as a `seq` accordingly to the command definition.\r\n\u003e\r\n\u003e This function runs synchronously.\r\n\r\nExample 1:\r\n```fsharp\r\ntype Row\u003c'T\u003e = { Set: int32; Record: int32; Data: 'T list }\r\n\r\nlet getCounterQuery n =\r\n    sprintf\r\n        \"\"\"\r\n        WITH RECURSIVE counter(value) AS (VALUES(1) UNION ALL SELECT value + 1 FROM counter WHERE value \u003c %d)\r\n        SELECT value FROM counter;\r\n        \"\"\" n\r\n\r\nlet readRow set record (read: SqlRecordReader\u003c_\u003e) =\r\n    { Set = set; Record = record; Data = List.init (read.Count) (read.Value\u003cint32\u003e) }\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\n[ 0; 1; 1; 2; 3; 5 ]\r\n|\u003e List.map getCounterQuery\r\n|\u003e PostgreSqlCommand.textFromList\r\n|\u003e PostgreSqlCommand.querySeqSync connection readRow\r\n|\u003e Seq.iter (fun x -\u003e printfn \"Set = %A; Row = %A; Data = %A\" x.Set x.Record x.Data)\r\n```\r\n\r\nOutput 1:\r\n```txt\r\nSet = 0; Row = 0; Data = [1]\r\nSet = 1; Row = 0; Data = [1]\r\nSet = 2; Row = 0; Data = [1]\r\nSet = 3; Row = 0; Data = [1]\r\nSet = 3; Row = 1; Data = [2]\r\nSet = 4; Row = 0; Data = [1]\r\nSet = 4; Row = 1; Data = [2]\r\nSet = 4; Row = 2; Data = [3]\r\nSet = 5; Row = 0; Data = [1]\r\nSet = 5; Row = 1; Data = [2]\r\nSet = 5; Row = 2; Data = [3]\r\nSet = 5; Row = 3; Data = [4]\r\nSet = 5; Row = 4; Data = [5]\r\n```\r\n\r\nNotes 📝:\r\n- The output type must be consistent across all the result sets and records.\r\n- If you need different types you may want to either:\r\n  - Create DU with each type you want to output\r\n  - Use `querySetList2` or `querySetList3` ⬇️\r\n- The `read`er can also get the `Value` given a certain field name:\r\n\r\nExample 2:\r\n```fsharp\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\n[ 0; 1; 1; 2; 3; 5; 8; 13; 21; 34; 55; ]\r\n|\u003e List.map (sprintf \"SELECT %d AS cola;\")\r\n|\u003e PostgreSqlCommand.textFromList\r\n|\u003e PostgreSqlCommand.queryList connection (fun _ _ read -\u003e read.Value\u003cint32\u003e \"cola\")\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput 2:\r\n```txt\r\n[0; 1; 1; 2; 3; 5; 8; 13; 21; 34; 55]\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003equeryList\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Execute the command and return the sets of rows as a list accordingly to the command definition.\r\n\u003e\r\n\u003e This function runs asynchronously.\r\n\r\nExample:\r\n```fsharp\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\n[ 0; 1; 1; 2; 3; 5; 8; 13; 21; 34; 55; ]\r\n|\u003e List.map (sprintf \"SELECT %d;\")\r\n|\u003e PostgreSqlCommand.textFromList\r\n|\u003e PostgreSqlCommand.queryList connection (fun _ _ read -\u003e read.Value\u003cint32\u003e 0)\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput:\r\n```txt\r\n[0; 1; 1; 2; 3; 5; 8; 13; 21; 34; 55]\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003equeryListSync\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Execute the command and return the sets of rows as a list accordingly to the command definition.\r\n\u003e\r\n\u003e This function runs synchronously.\r\n\r\nExample:\r\n```fsharp\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\n[ 0; 1; 1; 2; 3; 5; 8; 13; 21; 34; 55; ]\r\n|\u003e List.map (sprintf \"SELECT %d;\")\r\n|\u003e PostgreSqlCommand.textFromList\r\n|\u003e PostgreSqlCommand.queryListSync connection (fun _ _ read -\u003e read.Value\u003cint32\u003e 0)\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput:\r\n```txt\r\n[0; 1; 1; 2; 3; 5; 8; 13; 21; 34; 55]\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003equerySetList\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Execute the command and return the first set of rows as a list accordingly to the command definition.\r\n\u003e\r\n\u003e This function runs asynchronously.\r\n\r\nExample:\r\n```fsharp\r\ntype Row\u003c'T\u003e = { Set: int32; Record: int32; Data: 'T list }\r\n\r\nlet readRow set record (read: SqlRecordReader\u003c_\u003e)  =\r\n    { Set = set; Record = record; Data = List.init (read.Count) (read.Value\u003cint32\u003e) }\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\n[ 0; 1; 1; 2; 3; 5 ]\r\n|\u003e List.map (sprintf \"SELECT %d;\")\r\n|\u003e PostgreSqlCommand.textFromList\r\n|\u003e PostgreSqlCommand.querySetList connection (readRow 1)\r\n|\u003e Async.RunSynchronously\r\n|\u003e List.iter (fun x -\u003e printfn \"Set = %A; Row = %A; Data = %A\" x.Set x.Record x.Data)\r\n```\r\n\r\nOutput:\r\n```txt\r\nSet = 1; Row = 0; Data = [0]\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003equerySetListSync\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Execute the command and return the first set of rows as a list accordingly to the command definition.\r\n\u003e\r\n\u003e This function runs synchronously.\r\n\r\nExample:\r\n```fsharp\r\ntype Row\u003c'T\u003e = { Set: int32; Record: int32; Data: 'T list }\r\n\r\nlet readRow set record (read: SqlRecordReader\u003c_\u003e)  =\r\n    { Set = set; Record = record; Data = List.init (read.Count) (read.Value\u003cint32\u003e) }\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\n[ 0; 1; 1; 2; 3; 5 ]\r\n|\u003e List.map (sprintf \"SELECT %d;\")\r\n|\u003e PostgreSqlCommand.textFromList\r\n|\u003e PostgreSqlCommand.querySetListSync connection (readRow 1)\r\n|\u003e List.iter (fun x -\u003e printfn \"Set = %A; Row = %A; Data = %A\" x.Set x.Record x.Data)\r\n```\r\n\r\nOutput:\r\n```txt\r\nSet = 1; Row = 0; Data = [0]\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003equerySetList2\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Execute the command and return the 2 first sets of rows as a tuple of 2 lists accordingly to the command definition.\r\n\u003e\r\n\u003e This function runs asynchronously.\r\n\r\nExample:\r\n```fsharp\r\ntype Row\u003c'T\u003e = { Set: int32; Record: int32; Data: 'T list }\r\n\r\nlet readRow set record (read: SqlRecordReader\u003c_\u003e)  =\r\n    { Set = set; Record = record; Data = List.init (read.Count) (read.Value\u003cint32\u003e) }\r\n\r\nlet printRow row = printfn \"Set = %A; Row = %A; Data = %A\" row.Set row.Record row.Data\r\n\r\nlet set1, set2 =\r\n    use connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\n    [ 0; 1; 1; 2; 3; 5 ]\r\n    |\u003e List.map (sprintf \"SELECT %d;\")\r\n    |\u003e PostgreSqlCommand.textFromList\r\n    |\u003e PostgreSqlCommand.querySetList2 connection (readRow 1) (readRow 2)\r\n    |\u003e Async.RunSynchronously\r\n\r\nList.iter printRow set1\r\nList.iter printRow set2\r\n```\r\n\r\nOutput:\r\n```txt\r\nSet = 1; Row = 0; Data = [0]\r\nSet = 2; Row = 0; Data = [1]\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003equerySetList2Sync\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Execute the command and return the 2 first sets of rows as a tuple of 2 lists accordingly to the command definition.\r\n\u003e\r\n\u003e This function runs synchronously.\r\n\r\nExample:\r\n```fsharp\r\ntype Row\u003c'T\u003e = { Set: int32; Record: int32; Data: 'T list }\r\n\r\nlet readRow set record (read: SqlRecordReader\u003c_\u003e)  =\r\n    { Set = set; Record = record; Data = List.init (read.Count) (read.Value\u003cint32\u003e) }\r\n\r\nlet printRow row = printfn \"Set = %A; Row = %A; Data = %A\" row.Set row.Record row.Data\r\n\r\nlet set1, set2 =\r\n    use connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\n    [ 0; 1; 1; 2; 3; 5 ]\r\n    |\u003e List.map (sprintf \"SELECT %d;\")\r\n    |\u003e PostgreSqlCommand.textFromList\r\n    |\u003e PostgreSqlCommand.querySetList2Sync connection (readRow 1) (readRow 2)\r\n\r\nList.iter printRow set1\r\nList.iter printRow set2\r\n```\r\n\r\nOutput:\r\n```txt\r\nSet = 1; Row = 0; Data = [0]\r\nSet = 2; Row = 0; Data = [1]\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003equerySetList3\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Execute the command and return the 3 first sets of rows as a tuple of 3 lists accordingly to the command definition.\r\n\u003e\r\n\u003e This function runs asynchronously.\r\n\r\nExample:\r\n```fsharp\r\ntype Row\u003c'T\u003e = { Set: int32; Record: int32; Data: 'T list }\r\n\r\nlet readRow set record (read: SqlRecordReader\u003c_\u003e)  =\r\n    { Set = set; Record = record; Data = List.init (read.Count) (read.Value\u003cint32\u003e) }\r\n\r\nlet printRow row = printfn \"Set = %A; Row = %A; Data = %A\" row.Set row.Record row.Data\r\n\r\nlet set1, set2, set3 =\r\n    use connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\n    [ 0; 1; 1; 2; 3; 5 ]\r\n    |\u003e List.map (sprintf \"SELECT %d;\")\r\n    |\u003e PostgreSqlCommand.textFromList\r\n    |\u003e PostgreSqlCommand.querySetList3 connection (readRow 1) (readRow 2) (readRow 3)\r\n    |\u003e Async.RunSynchronously\r\n\r\nList.iter printRow set1\r\nList.iter printRow set2\r\nList.iter printRow set3\r\n```\r\n\r\nOutput:\r\n```txt\r\nSet = 1; Row = 0; Data = [0]\r\nSet = 2; Row = 0; Data = [1]\r\nSet = 3; Row = 0; Data = [1]\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003equerySetList3Sync\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Execute the command and return the 3 first sets of rows as a tuple of 3 lists accordingly to the command definition.\r\n\u003e\r\n\u003e This function runs synchronously.\r\n\r\nExample:\r\n```fsharp\r\ntype Row\u003c'T\u003e = { Set: int32; Record: int32; Data: 'T list }\r\n\r\nlet readRow set record (read: SqlRecordReader\u003c_\u003e)  =\r\n    { Set = set; Record = record; Data = List.init (read.Count) (read.Value\u003cint32\u003e) }\r\n\r\nlet printRow row = printfn \"Set = %A; Row = %A; Data = %A\" row.Set row.Record row.Data\r\n\r\nlet set1, set2, set3 =\r\n    use connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\n    [ 0; 1; 1; 2; 3; 5 ]\r\n    |\u003e List.map (sprintf \"SELECT %d;\")\r\n    |\u003e PostgreSqlCommand.textFromList\r\n    |\u003e PostgreSqlCommand.querySetList3Sync connection (readRow 1) (readRow 2) (readRow 3)\r\n\r\nList.iter printRow set1\r\nList.iter printRow set2\r\nList.iter printRow set3\r\n```\r\n\r\nOutput:\r\n```txt\r\nSet = 1; Row = 0; Data = [0]\r\nSet = 2; Row = 0; Data = [1]\r\nSet = 3; Row = 0; Data = [1]\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003eexecuteScalar\u003c'Scalar\u003e\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Execute the command accordingly to its definition and,\r\n\u003e - return the first cell value, if it is available and of the given type.\r\n\u003e - throw an exception, otherwise.\r\n\u003e\r\n\u003e This function runs asynchronously.\r\n\r\nExample:\r\n```fsharp\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nPostgreSqlCommand.text \"SELECT 42;\"\r\n|\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput:\r\n```txt\r\n42\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003eexecuteScalarSync\u003c'Scalar\u003e\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Execute the command accordingly to its definition and,\r\n\u003e - return the first cell value, if it is available and of the given type.\r\n\u003e - throw an exception, otherwise.\r\n\u003e\r\n\u003e This function runs synchronously.\r\n\r\nExample:\r\n```fsharp\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nPostgreSqlCommand.text \"SELECT 42;\"\r\n|\u003e PostgreSqlCommand.executeScalarSync\u003cint32\u003e connection\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput:\r\n```txt\r\n42\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003eexecuteScalarOrNone\u003c'Scalar\u003e\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Execute the command accordingly to its definition and,\r\n\u003e - return `Some`, if the first cell is available and of the given type.\r\n\u003e - return `None`, if first cell is `DBNull`.\r\n\u003e - throw an exception, otherwise.\r\n\u003e\r\n\u003e This function runs asynchronously.\r\n\r\nExample:\r\n```fsharp\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\n\r\nPostgreSqlCommand.text \"SELECT 42;\"\r\n|\u003e PostgreSqlCommand.executeScalarOrNone\u003cint32\u003e connection\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n\r\nPostgreSqlCommand.text \"SELECT NUL;\"\r\n|\u003e PostgreSqlCommand.executeScalarOrNone\u003cint32\u003e connection\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n0\r\n```\r\n\r\nOutput:\r\n```txt\r\nSome 42\r\nNone\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003eexecuteScalarOrNoneSync\u003c'Scalar\u003e\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Execute the command accordingly to its definition and,\r\n\u003e - return `Some`, if the first cell is available and of the given type.\r\n\u003e - return `None`, if first cell is `DBNull`.\r\n\u003e - throw an exception, otherwise.\r\n\u003e\r\n\u003e This function runs synchronously.\r\n\r\nExample:\r\n```fsharp\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\n\r\nPostgreSqlCommand.text \"SELECT 42;\"\r\n|\u003e PostgreSqlCommand.executeScalarOrNoneSync\u003cint32\u003e connection\r\n|\u003e printfn \"%A\"\r\n\r\nPostgreSqlCommand.text \"SELECT NULL;\"\r\n|\u003e PostgreSqlCommand.executeScalarOrNoneSync\u003cint32\u003e connection\r\n|\u003e printfn \"%A\"\r\n0\r\n```\r\n\r\nOutput:\r\n```txt\r\nSome 42\r\nNone\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003eexecuteNonQuery\u003c'Scalar\u003e\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Execute the command accordingly to its definition and, return the number of rows affected.\r\n\u003e\r\n\u003e This function runs asynchronously.\r\n\r\nExample:\r\n```fsharp\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nPostgreSqlCommand.text \"SELECT 42;\"\r\n|\u003e PostgreSqlCommand.executeNonQuery connection\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput:\r\n```txt\r\n-1\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003eexecuteNonQuerySync\u003c'Scalar\u003e\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Execute the command accordingly to its definition and, return the number of rows affected.\r\n\u003e\r\n\u003e This function runs synchronously.\r\n\r\nExample:\r\n```fsharp\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nPostgreSqlCommand.text \"SELECT 42;\"\r\n|\u003e PostgreSqlCommand.executeNonQuerySync connection\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput:\r\n```txt\r\n-1\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n## 🦮 `PostgreSqlNullDbValue`: Null Helpers\r\n\r\nThe module to handle options and results in parameters.\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003eifNone\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Return PostgreSql DB Null value if the given option is `None`, otherwise the underlying wrapped in `Some`.\r\n\r\nExample:\r\n```fsharp\r\n[ \"a\", PostgreSqlNullDbValue.ifNone Integer (Some 42)\r\n  \"b\", PostgreSqlNullDbValue.ifNone Integer (None) ]\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput:\r\n```txt\r\n[(\"a\", Integer 42); (\"b\", Null)]\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003eifError\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Return PostgreSql DB Null value if the given option is `Error`, otherwise the underlying wrapped in `Ok`.\r\n\r\nExample:\r\n```fsharp\r\n[ \"a\", PostgreSqlNullDbValue.ifError Integer (Ok 42)\r\n  \"b\", PostgreSqlNullDbValue.ifError Integer (Error \"meh\") ]\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput:\r\n```txt\r\n[(\"a\", Integer 42); (\"b\", Null)]\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n## 🚄 `PostgreSqlTransaction`: Transaction Helpers\r\n\r\nThis is the main module to interact with `NpgsqlTransaction`.\r\n\r\n📝 Note: The default isolation level is [`ReadCommitted`](https://docs.microsoft.com/en-us/dotnet/api/system.data.isolationlevel).\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003ecommit\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Create and commit an automatically generated transaction with the given connection, isolation, cancellation token and transaction body.\r\n\u003e\r\n\u003e This function runs asynchronously.\r\n\r\nExample:\r\n```fsharp\r\nlet tableName = \"people\"\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nconnection.Open()\r\n\r\nPostgreSqlTransaction.commit (CancellationToken.None) (IsolationLevel.ReadCommitted) connection (fun connection _ -\u003e async {\r\n    do! $\"CREATE TABLE {tableName} (id SERIAL PRIMARY KEY, name TEXT NOT NULL);\"\r\n        |\u003e PostgreSqlCommand.text \r\n        |\u003e PostgreSqlCommand.executeNonQuery connection\r\n        |\u003e Async.Ignore\r\n\r\n    return!\r\n        PostgreSqlCommand.text $\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n        |\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n})\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n\r\n$\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n|\u003e PostgreSqlCommand.text \r\n|\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput:\r\n```txt\r\n1\r\n1\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003ecommitSync\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Create and commit an automatically generated transaction with the given connection, isolation and transaction body.\r\n\u003e\r\n\u003e This function runs synchronously.\r\n\r\nExample:\r\n```fsharp\r\nlet tableName = \"people\"\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nconnection.Open()\r\n\r\nPostgreSqlTransaction.commitSync (IsolationLevel.ReadCommitted) connection (fun connection _ -\u003e\r\n    $\"CREATE TABLE {tableName} (id SERIAL PRIMARY KEY, name TEXT NOT NULL);\"\r\n    |\u003e PostgreSqlCommand.text \r\n    |\u003e PostgreSqlCommand.executeNonQuerySync connection\r\n    |\u003e ignore\r\n\r\n    PostgreSqlCommand.text $\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n    |\u003e PostgreSqlCommand.executeScalarSync\u003cint32\u003e connection\r\n)\r\n|\u003e printfn \"%A\"\r\n\r\n$\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n|\u003e PostgreSqlCommand.text \r\n|\u003e PostgreSqlCommand.executeScalarSync\u003cint32\u003e connection\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput:\r\n```txt\r\n1\r\n1\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003enotCommit\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Create and do not commit an automatically generated transaction with the given connection, isolation, cancellation token and transaction body.\r\n\u003e\r\n\u003e This function runs synchronously.\r\n\r\nExample:\r\n```fsharp\r\nlet tableName = \"people\"\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nconnection.Open()\r\n\r\nPostgreSqlTransaction.notCommit (CancellationToken.None) (IsolationLevel.ReadCommitted) connection (fun connection _ -\u003e async {\r\n    do! $\"CREATE TABLE {tableName} (id SERIAL PRIMARY KEY, name TEXT NOT NULL);\" \r\n        |\u003e PostgreSqlCommand.text\r\n        |\u003e PostgreSqlCommand.executeNonQuery connection\r\n        |\u003e Async.Ignore\r\n\r\n    return!\r\n        $\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n        |\u003e PostgreSqlCommand.text\r\n        |\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n})\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n\r\n$\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n|\u003e PostgreSqlCommand.text \r\n|\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput:\r\n```txt\r\n1\r\n0\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003enotCommitSync\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Create and do not commit an automatically generated transaction with the given connection, isolation and transaction body.\r\n\u003e\r\n\u003e This function runs synchronously.\r\n\r\nExample:\r\n```fsharp\r\nlet tableName = \"people\"\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nconnection.Open()\r\n\r\nPostgreSqlTransaction.notCommitSync (IsolationLevel.ReadCommitted) connection (fun connection _ -\u003e \r\n    $\"CREATE TABLE {tableName} (id SERIAL PRIMARY KEY, name TEXT NOT NULL);\" \r\n    |\u003e PostgreSqlCommand.text\r\n    |\u003e PostgreSqlCommand.executeNonQuery connection\r\n    |\u003e ignore\r\n\r\n    $\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n    |\u003e PostgreSqlCommand.text\r\n    |\u003e PostgreSqlCommand.executeScalarSync\u003cint32\u003e connection\r\n)\r\n|\u003e printfn \"%A\"\r\n\r\n$\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n|\u003e PostgreSqlCommand.text \r\n|\u003e PostgreSqlCommand.executeScalarSync\u003cint32\u003e connection\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput:\r\n```txt\r\n1\r\n0\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003ecommitOnSome\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Create and commit an automatically generated transaction with the given connection, isolation, cancellation token and transaction body.\r\n\u003e\r\n\u003e The commit phase only occurs if the transaction body returns Some.\r\n\u003e\r\n\u003e This function runs asynchronously.\r\n\r\nExample 1:\r\n```fsharp\r\nlet tableName = \"people\"\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nconnection.Open()\r\n\r\nPostgreSqlTransaction.commitOnSome (CancellationToken.None) (IsolationLevel.ReadCommitted) connection (fun connection _ -\u003e async {\r\n    do! $\"CREATE TABLE {tableName} (id SERIAL PRIMARY KEY, name TEXT NOT NULL);\"\r\n        |\u003e PostgreSqlCommand.text \r\n        |\u003e PostgreSqlCommand.executeNonQuery connection\r\n        |\u003e Async.Ignore\r\n\r\n    do! $\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n        |\u003e PostgreSqlCommand.text\r\n        |\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n        |\u003e Async.Ignore\r\n    return Some 42\r\n})\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n\r\n$\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n|\u003e PostgreSqlCommand.text \r\n|\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput 1:\r\n```txt\r\nSome 42\r\n1\r\n```\r\n\r\nExample 2:\r\n```fsharp\r\nlet tableName = \"people\"\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nconnection.Open()\r\n\r\nPostgreSqlTransaction.commitOnSome (CancellationToken.None) (IsolationLevel.ReadCommitted) connection (fun connection _ -\u003e async {\r\n    do! $\"CREATE TABLE {tableName} (id SERIAL PRIMARY KEY, name TEXT NOT NULL);\"\r\n        |\u003e PostgreSqlCommand.text \r\n        |\u003e PostgreSqlCommand.executeNonQuery connection\r\n        |\u003e Async.Ignore\r\n\r\n    do! $\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\" \r\n        |\u003e PostgreSqlCommand.text \r\n        |\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n        |\u003e Async.Ignore\r\n    return None\r\n})\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n\r\n$\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n|\u003e PostgreSqlCommand.text \r\n|\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput 2:\r\n```txt\r\nNone\r\n0\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003ecommitOnSomeSync\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Create and commit an automatically generated transaction with the given connection, isolation and transaction body.\r\n\u003e\r\n\u003e The commit phase only occurs if the transaction body returns Some.\r\n\u003e\r\n\u003e This function runs synchronously.\r\n\r\nExample 1:\r\n```fsharp\r\nlet tableName = \"people\"\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nconnection.Open()\r\n\r\nPostgreSqlTransaction.commitOnSomeSync (IsolationLevel.ReadCommitted) connection (fun connection _ -\u003e \r\n    $\"CREATE TABLE {tableName} (id SERIAL PRIMARY KEY, name TEXT NOT NULL);\"\r\n    |\u003e PostgreSqlCommand.text \r\n    |\u003e PostgreSqlCommand.executeNonQuerySync connection\r\n    |\u003e ignore\r\n\r\n    $\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n    |\u003e PostgreSqlCommand.text\r\n    |\u003e PostgreSqlCommand.executeScalarSync\u003cint32\u003e connection\r\n    |\u003e ignore\r\n    return Some 42\r\n)\r\n|\u003e printfn \"%A\"\r\n\r\n$\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n|\u003e PostgreSqlCommand.text \r\n|\u003e PostgreSqlCommand.executeScalarSync\u003cint32\u003e connection\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput 1:\r\n```txt\r\nSome 42\r\n1\r\n```\r\n\r\nExample 2:\r\n```fsharp\r\nlet tableName = \"people\"\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nconnection.Open()\r\n\r\nPostgreSqlTransaction.commitOnSomeSync (IsolationLevel.ReadCommitted) connection (fun connection _ -\u003e\r\n    $\"CREATE TABLE {tableName} (id SERIAL PRIMARY KEY, name TEXT NOT NULL);\"\r\n    |\u003e PostgreSqlCommand.text \r\n    |\u003e PostgreSqlCommand.executeNonQuerySync connection\r\n    |\u003e ignore\r\n\r\n    $\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\" \r\n    |\u003e PostgreSqlCommand.text \r\n    |\u003e PostgreSqlCommand.executeScalarSync\u003cint32\u003e connection\r\n    |\u003e ignore\r\n    return None\r\n)\r\n|\u003e printfn \"%A\"\r\n\r\n$\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n|\u003e PostgreSqlCommand.text \r\n|\u003e PostgreSqlCommand.executeScalarSync\u003cint32\u003e connection\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput 2:\r\n```txt\r\nNone\r\n0\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003ecommitOnOk\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Create and commit an automatically generated transaction with the given connection, isolation, cancellation token and transaction body.\r\n\u003e\r\n\u003e The commit phase only occurs if the transaction body returns Ok.\r\n\u003e\r\n\u003e This function runs asynchronously.\r\n\r\nExample 1:\r\n```fsharp\r\nlet tableName = \"people\"\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nconnection.Open()\r\n\r\nPostgreSqlTransaction.commitOnOk (CancellationToken.None) (IsolationLevel.ReadCommitted) connection (fun connection _ -\u003e async {\r\n    do! $\"CREATE TABLE {tableName} (id SERIAL PRIMARY KEY, name TEXT NOT NULL);\"\r\n        |\u003e PostgreSqlCommand.text\r\n        |\u003e PostgreSqlCommand.executeNonQuery connection\r\n        |\u003e Async.Ignore\r\n\r\n    do! $\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n        |\u003e PostgreSqlCommand.text \r\n        |\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n        |\u003e Async.Ignore\r\n    return Ok 42\r\n})\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n\r\n$\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n|\u003e PostgreSqlCommand.text \r\n|\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput 1:\r\n```txt\r\nOk 42\r\n1\r\n```\r\n\r\nExample 2:\r\n```fsharp\r\nlet tableName = \"people\"\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nconnection.Open()\r\n\r\nPostgreSqlTransaction.commitOnOk (CancellationToken.None) (IsolationLevel.ReadCommitted) connection (fun connection _ -\u003e async {\r\n    do! $\"CREATE TABLE {tableName} (id SERIAL PRIMARY KEY, name TEXT NOT NULL);\"\r\n        |\u003e PostgreSqlCommand.text \r\n        |\u003e PostgreSqlCommand.executeNonQuery connection\r\n        |\u003e Async.Ignore\r\n\r\n    do! $\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n        |\u003e PostgreSqlCommand.text\r\n        |\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n        |\u003e Async.Ignore\r\n    return Error \"fail\"\r\n})\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n\r\n$\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n|\u003e PostgreSqlCommand.text \r\n|\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput 2:\r\n```txt\r\nError \"fail\"\r\n0\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003ecommitOnOkSync\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Create and commit an automatically generated transaction with the given connection, isolation and transaction body.\r\n\u003e\r\n\u003e The commit phase only occurs if the transaction body returns Ok.\r\n\u003e\r\n\u003e This function runs synchronously.\r\n\r\nExample 1:\r\n```fsharp\r\nlet tableName = \"people\"\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nconnection.Open()\r\n\r\nPostgreSqlTransaction.commitOnOkSync (IsolationLevel.ReadCommitted) connection (fun connection _ -\u003e\r\n    $\"CREATE TABLE {tableName} (id SERIAL PRIMARY KEY, name TEXT NOT NULL);\"\r\n    |\u003e PostgreSqlCommand.text\r\n    |\u003e PostgreSqlCommand.executeNonQuerySync connection\r\n    |\u003e ignore\r\n\r\n    $\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n    |\u003e PostgreSqlCommand.text \r\n    |\u003e PostgreSqlCommand.executeScalarSync\u003cint32\u003e connection\r\n    |\u003e ignore\r\n    return Ok 42\r\n)\r\n|\u003e printfn \"%A\"\r\n\r\n$\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n|\u003e PostgreSqlCommand.text \r\n|\u003e PostgreSqlCommand.executeScalarSync\u003cint32\u003e connection\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput 1:\r\n```txt\r\nOk 42\r\n1\r\n```\r\n\r\nExample 2:\r\n```fsharp\r\nlet tableName = \"people\"\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nconnection.Open()\r\n\r\nPostgreSqlTransaction.commitOnOkSync (IsolationLevel.ReadCommitted) connection (fun connection _ -\u003e\r\n    $\"CREATE TABLE {tableName} (id SERIAL PRIMARY KEY, name TEXT NOT NULL);\"\r\n    |\u003e PostgreSqlCommand.text \r\n    |\u003e PostgreSqlCommand.executeNonQuerySync connection\r\n    |\u003e ignore\r\n\r\n    $\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n    |\u003e PostgreSqlCommand.text\r\n    |\u003e PostgreSqlCommand.executeScalarSync\u003cint32\u003e connection\r\n    |\u003e ignore\r\n    return Error \"fail\"\r\n)\r\n|\u003e printfn \"%A\"\r\n\r\n$\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n|\u003e PostgreSqlCommand.text \r\n|\u003e PostgreSqlCommand.executeScalarSync\u003cint32\u003e connection\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput 2:\r\n```txt\r\nError \"fail\"\r\n0\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003edefaultCommit\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Create and commit an automatically generated transaction with the given connection and transaction body.\r\n\u003e\r\n\u003e This function runs asynchronously.\r\n\r\nExample:\r\n```fsharp\r\nlet tableName = \"people\"\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nconnection.Open()\r\n\r\nPostgreSqlTransaction.defaultCommit connection (fun connection _ -\u003e async {\r\n    do! $\"CREATE TABLE {tableName} (id SERIAL PRIMARY KEY, name TEXT NOT NULL);\"\r\n        |\u003e PostgreSqlCommand.text \r\n        |\u003e PostgreSqlCommand.executeNonQuery connection\r\n        |\u003e Async.Ignore\r\n\r\n    return!\r\n        PostgreSqlCommand.text $\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n        |\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n})\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n\r\n$\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n|\u003e PostgreSqlCommand.text \r\n|\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput:\r\n```txt\r\n1\r\n1\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003edefaultCommitSync\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Create and commit an automatically generated transaction with the given connection and transaction body.\r\n\u003e\r\n\u003e This function runs synchronously.\r\n\r\nExample:\r\n```fsharp\r\nlet tableName = \"people\"\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nconnection.Open()\r\n\r\nPostgreSqlTransaction.defaultCommitSync connection (fun connection _ -\u003e\r\n    $\"CREATE TABLE {tableName} (id SERIAL PRIMARY KEY, name TEXT NOT NULL);\"\r\n    |\u003e PostgreSqlCommand.text \r\n    |\u003e PostgreSqlCommand.executeNonQuerySync connection\r\n    |\u003e ignore\r\n\r\n    PostgreSqlCommand.text $\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n    |\u003e PostgreSqlCommand.executeScalarSync\u003cint32\u003e connection\r\n)\r\n|\u003e printfn \"%A\"\r\n\r\n$\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n|\u003e PostgreSqlCommand.text \r\n|\u003e PostgreSqlCommand.executeScalarSync\u003cint32\u003e connection\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput:\r\n```txt\r\n1\r\n1\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003edefaultNotCommit\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Create and do not commit an automatically generated transaction with the given connection and transaction body.\r\n\u003e\r\n\u003e This function runs synchronously.\r\n\r\nExample:\r\n```fsharp\r\nlet tableName = \"people\"\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nconnection.Open()\r\n\r\nPostgreSqlTransaction.defaultNotCommit connection (fun connection _ -\u003e async {\r\n    do! $\"CREATE TABLE {tableName} (id SERIAL PRIMARY KEY, name TEXT NOT NULL);\" \r\n        |\u003e PostgreSqlCommand.text\r\n        |\u003e PostgreSqlCommand.executeNonQuery connection\r\n        |\u003e Async.Ignore\r\n\r\n    return!\r\n        $\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n        |\u003e PostgreSqlCommand.text\r\n        |\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n})\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n\r\n$\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n|\u003e PostgreSqlCommand.text \r\n|\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput:\r\n```txt\r\n1\r\n0\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003edefaultNotCommitSync\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Create and do not commit an automatically generated transaction with the given connection and transaction body.\r\n\u003e\r\n\u003e This function runs synchronously.\r\n\r\nExample:\r\n```fsharp\r\nlet tableName = \"people\"\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nconnection.Open()\r\n\r\nPostgreSqlTransaction.defaultNotCommitSync connection (fun connection _ -\u003e \r\n    $\"CREATE TABLE {tableName} (id SERIAL PRIMARY KEY, name TEXT NOT NULL);\" \r\n    |\u003e PostgreSqlCommand.text\r\n    |\u003e PostgreSqlCommand.executeNonQuery connection\r\n    |\u003e ignore\r\n\r\n    $\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n    |\u003e PostgreSqlCommand.text\r\n    |\u003e PostgreSqlCommand.executeScalarSync\u003cint32\u003e connection\r\n)\r\n|\u003e printfn \"%A\"\r\n\r\n$\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n|\u003e PostgreSqlCommand.text \r\n|\u003e PostgreSqlCommand.executeScalarSync\u003cint32\u003e connection\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput:\r\n```txt\r\n1\r\n0\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003edefaultCommitOnSome\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Create and commit an automatically generated transaction with the given connection and transaction body.\r\n\u003e\r\n\u003e The commit phase only occurs if the transaction body returns Some.\r\n\u003e\r\n\u003e This function runs asynchronously.\r\n\r\nExample 1:\r\n```fsharp\r\nlet tableName = \"people\"\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nconnection.Open()\r\n\r\nPostgreSqlTransaction.defaultCommitOnSome connection (fun connection _ -\u003e async {\r\n    do! $\"CREATE TABLE {tableName} (id SERIAL PRIMARY KEY, name TEXT NOT NULL);\"\r\n        |\u003e PostgreSqlCommand.text \r\n        |\u003e PostgreSqlCommand.executeNonQuery connection\r\n        |\u003e Async.Ignore\r\n\r\n    do! $\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n        |\u003e PostgreSqlCommand.text\r\n        |\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n        |\u003e Async.Ignore\r\n    return Some 42\r\n})\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n\r\n$\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n|\u003e PostgreSqlCommand.text \r\n|\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput 1:\r\n```txt\r\nSome 42\r\n1\r\n```\r\n\r\nExample 2:\r\n```fsharp\r\nlet tableName = \"people\"\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nconnection.Open()\r\n\r\nPostgreSqlTransaction.defaultCommitOnSome connection (fun connection _ -\u003e async {\r\n    do! $\"CREATE TABLE {tableName} (id SERIAL PRIMARY KEY, name TEXT NOT NULL);\"\r\n        |\u003e PostgreSqlCommand.text \r\n        |\u003e PostgreSqlCommand.executeNonQuery connection\r\n        |\u003e Async.Ignore\r\n\r\n    do! $\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\" \r\n        |\u003e PostgreSqlCommand.text \r\n        |\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n        |\u003e Async.Ignore\r\n    return None\r\n})\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n\r\n$\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n|\u003e PostgreSqlCommand.text \r\n|\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput 2:\r\n```txt\r\nNone\r\n0\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003edefaultCommitOnSomeSync\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Create and commit an automatically generated transaction with the given connection and transaction body.\r\n\u003e\r\n\u003e The commit phase only occurs if the transaction body returns Some.\r\n\u003e\r\n\u003e This function runs synchronously.\r\n\r\nExample 1:\r\n```fsharp\r\nlet tableName = \"people\"\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nconnection.Open()\r\n\r\nPostgreSqlTransaction.defaultCommitOnSomeSync connection (fun connection _ -\u003e \r\n    $\"CREATE TABLE {tableName} (id SERIAL PRIMARY KEY, name TEXT NOT NULL);\"\r\n    |\u003e PostgreSqlCommand.text \r\n    |\u003e PostgreSqlCommand.executeNonQuerySync connection\r\n    |\u003e ignore\r\n\r\n    $\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n    |\u003e PostgreSqlCommand.text\r\n    |\u003e PostgreSqlCommand.executeScalarSync\u003cint32\u003e connection\r\n    |\u003e ignore\r\n    return Some 42\r\n)\r\n|\u003e printfn \"%A\"\r\n\r\n$\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n|\u003e PostgreSqlCommand.text \r\n|\u003e PostgreSqlCommand.executeScalarSync\u003cint32\u003e connection\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput 1:\r\n```txt\r\nSome 42\r\n1\r\n```\r\n\r\nExample 2:\r\n```fsharp\r\nlet tableName = \"people\"\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nconnection.Open()\r\n\r\nPostgreSqlTransaction.defaultCommitOnSomeSync connection (fun connection _ -\u003e\r\n    $\"CREATE TABLE {tableName} (id SERIAL PRIMARY KEY, name TEXT NOT NULL);\"\r\n    |\u003e PostgreSqlCommand.text \r\n    |\u003e PostgreSqlCommand.executeNonQuerySync connection\r\n    |\u003e ignore\r\n\r\n    $\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\" \r\n    |\u003e PostgreSqlCommand.text \r\n    |\u003e PostgreSqlCommand.executeScalarSync\u003cint32\u003e connection\r\n    |\u003e ignore\r\n    return None\r\n)\r\n|\u003e printfn \"%A\"\r\n\r\n$\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n|\u003e PostgreSqlCommand.text \r\n|\u003e PostgreSqlCommand.executeScalarSync\u003cint32\u003e connection\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput 2:\r\n```txt\r\nNone\r\n0\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003edefaultCommitOnOk\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Create and commit an automatically generated transaction with the given connection and transaction body.\r\n\u003e\r\n\u003e The commit phase only occurs if the transaction body returns Ok.\r\n\u003e\r\n\u003e This function runs asynchronously.\r\n\r\nExample 1:\r\n```fsharp\r\nlet tableName = \"people\"\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nconnection.Open()\r\n\r\nPostgreSqlTransaction.defaultCommitOnOk connection (fun connection _ -\u003e async {\r\n    do! $\"CREATE TABLE {tableName} (id SERIAL PRIMARY KEY, name TEXT NOT NULL);\"\r\n        |\u003e PostgreSqlCommand.text\r\n        |\u003e PostgreSqlCommand.executeNonQuery connection\r\n        |\u003e Async.Ignore\r\n\r\n    do! $\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n        |\u003e PostgreSqlCommand.text \r\n        |\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n        |\u003e Async.Ignore\r\n    return Ok 42\r\n})\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n\r\n$\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n|\u003e PostgreSqlCommand.text \r\n|\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput 1:\r\n```txt\r\nOk 42\r\n1\r\n```\r\n\r\nExample 2:\r\n```fsharp\r\nlet tableName = \"people\"\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nconnection.Open()\r\n\r\nPostgreSqlTransaction.defaultCommitOnOk connection (fun connection _ -\u003e async {\r\n    do! $\"CREATE TABLE {tableName} (id SERIAL PRIMARY KEY, name TEXT NOT NULL);\"\r\n        |\u003e PostgreSqlCommand.text \r\n        |\u003e PostgreSqlCommand.executeNonQuery connection\r\n        |\u003e Async.Ignore\r\n\r\n    do! $\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n        |\u003e PostgreSqlCommand.text\r\n        |\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n        |\u003e Async.Ignore\r\n    return Error \"fail\"\r\n})\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n\r\n$\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n|\u003e PostgreSqlCommand.text \r\n|\u003e PostgreSqlCommand.executeScalar\u003cint32\u003e connection\r\n|\u003e Async.RunSynchronously\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput 2:\r\n```txt\r\nError \"fail\"\r\n0\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e \r\n\u003csummary\u003e\u003ccode\u003edefaultCommitOnOkSync\u003c/code\u003e\u003c/summary\u003e\r\n\r\n\u003e Create and commit an automatically generated transaction with the given connection and transaction body.\r\n\u003e\r\n\u003e The commit phase only occurs if the transaction body returns Ok.\r\n\u003e\r\n\u003e This function runs synchronously.\r\n\r\nExample 1:\r\n```fsharp\r\nlet tableName = \"people\"\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nconnection.Open()\r\n\r\nPostgreSqlTransaction.defaultCommitOnOkSync connection (fun connection _ -\u003e\r\n    $\"CREATE TABLE {tableName} (id SERIAL PRIMARY KEY, name TEXT NOT NULL);\"\r\n    |\u003e PostgreSqlCommand.text\r\n    |\u003e PostgreSqlCommand.executeNonQuerySync connection\r\n    |\u003e ignore\r\n\r\n    $\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n    |\u003e PostgreSqlCommand.text \r\n    |\u003e PostgreSqlCommand.executeScalarSync\u003cint32\u003e connection\r\n    |\u003e ignore\r\n    return Ok 42\r\n)\r\n|\u003e printfn \"%A\"\r\n\r\n$\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n|\u003e PostgreSqlCommand.text \r\n|\u003e PostgreSqlCommand.executeScalarSync\u003cint32\u003e connection\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput 1:\r\n```txt\r\nOk 42\r\n1\r\n```\r\n\r\nExample 2:\r\n```fsharp\r\nlet tableName = \"people\"\r\n\r\nuse connection = new NpgsqlConnection(\"Host=localhost;Database=my_database;User ID=postgres;\")\r\nconnection.Open()\r\n\r\nPostgreSqlTransaction.defaultCommitOnOkSync connection (fun connection _ -\u003e\r\n    $\"CREATE TABLE {tableName} (id SERIAL PRIMARY KEY, name TEXT NOT NULL);\"\r\n    |\u003e PostgreSqlCommand.text \r\n    |\u003e PostgreSqlCommand.executeNonQuerySync connection\r\n    |\u003e ignore\r\n\r\n    $\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n    |\u003e PostgreSqlCommand.text\r\n    |\u003e PostgreSqlCommand.executeScalarSync\u003cint32\u003e connection\r\n    |\u003e ignore\r\n    return Error \"fail\"\r\n)\r\n|\u003e printfn \"%A\"\r\n\r\n$\"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{tableName}';\"\r\n|\u003e PostgreSqlCommand.text \r\n|\u003e PostgreSqlCommand.executeScalarSync\u003cint32\u003e connection\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\nOutput 2:\r\n```txt\r\nError \"fail\"\r\n0\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n# ❤ How to Contribute\r\nBug reports, feature requests, and pull requests are very welcome! Please read the [Contribution Guidelines](./CONTRIBUTION.md) to get started.\r\n\r\n# 📜 Licensing\r\nThe project is licensed under MIT. For more information on the license see the [license file](./LICENSE).\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fveepee-oss%2Fvp.fsharp.sql.postgresql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fveepee-oss%2Fvp.fsharp.sql.postgresql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fveepee-oss%2Fvp.fsharp.sql.postgresql/lists"}