{"id":15002618,"url":"https://github.com/zaid-ajaj/dustytables","last_synced_at":"2025-10-30T08:31:19.255Z","repository":{"id":49104274,"uuid":"168138110","full_name":"Zaid-Ajaj/DustyTables","owner":"Zaid-Ajaj","description":"Thin F# API for SqlClient for easy data access to ms sql server with functional seasoning on top","archived":false,"fork":false,"pushed_at":"2024-01-16T19:41:28.000Z","size":439,"stargazers_count":75,"open_issues_count":7,"forks_count":11,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-02T07:23:00.516Z","etag":null,"topics":["data-access","fsharp","mssql","sql"],"latest_commit_sha":null,"homepage":"","language":"F#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Zaid-Ajaj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2019-01-29T10:43:24.000Z","updated_at":"2024-12-21T23:19:24.000Z","dependencies_parsed_at":"2024-06-21T15:36:23.515Z","dependency_job_id":"adcc9df7-feee-487b-a242-48540ae456dc","html_url":"https://github.com/Zaid-Ajaj/DustyTables","commit_stats":{"total_commits":35,"total_committers":6,"mean_commits":5.833333333333333,"dds":0.2571428571428571,"last_synced_commit":"7477ab9c7b34f4d0e1d5416e82b41c68e310ddee"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zaid-Ajaj%2FDustyTables","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zaid-Ajaj%2FDustyTables/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zaid-Ajaj%2FDustyTables/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zaid-Ajaj%2FDustyTables/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Zaid-Ajaj","download_url":"https://codeload.github.com/Zaid-Ajaj/DustyTables/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238945668,"owners_count":19556700,"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":["data-access","fsharp","mssql","sql"],"created_at":"2024-09-24T18:51:32.338Z","updated_at":"2025-10-30T08:31:18.797Z","avatar_url":"https://github.com/Zaid-Ajaj.png","language":"F#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DustyTables [![Nuget](https://img.shields.io/nuget/v/DustyTables.svg?colorB=green)](https://www.nuget.org/packages/DustyTables)\n\nFunctional wrapper around plain old (dusty?) `SqlClient` to simplify data access when talking to MS Sql Server databases.\n\n## Install\n```bash\n# nuget client\ndotnet add package DustyTables\n```\n\n## Query a table\n```fs\nopen DustyTables\n\n// get the connection from the environment\nlet connectionString() = Env.getVar \"app_db\"\n\ntype User = { Id: int; Username: string }\n\nlet getUsers() : User list =\n    connectionString()\n    |\u003e Sql.connect\n    |\u003e Sql.query \"SELECT * FROM dbo.[Users]\"\n    |\u003e Sql.execute (fun read -\u003e\n        {\n            Id = read.int \"user_id\"\n            Username = read.string \"username\"\n        })\n```\n\n## Handle null values from table columns:\n```fs\nopen DustyTables\n\n// get the connection from the environment\nlet connectionString() = Env.getVar \"app_db\"\n\ntype User = { Id: int; Username: string; LastModified : Option\u003cDateTime\u003e }\n\nlet getUsers() : User list =\n    connectionString()\n    |\u003e Sql.connect\n    |\u003e Sql.query \"SELECT * FROM dbo.[users]\"\n    |\u003e Sql.execute(fun read -\u003e\n        {\n            Id = read.int \"user_id\"\n            Username = read.string \"username\"\n            // Notice here using `orNone` reader variants\n            LastModified = read.dateTimeOrNone \"last_modified\"\n        })\n```\n## Providing default values for null columns:\n```fs\nopen DustyTables\n\n// get the connection from the environment\nlet connectionString() = Env.getVar \"app_db\"\n\ntype User = { Id: int; Username: string; Biography : string }\n\nlet getUsers() : User list =\n    connectionString()\n    |\u003e Sql.connect\n    |\u003e Sql.query \"select * from dbo.[users]\"\n    |\u003e Sql.execute (fun read -\u003e\n        {\n            Id = read.int \"user_id\";\n            Username = read.string \"username\"\n            Biography = defaultArg (read.stringOrNone \"bio\") \"\"\n        })\n```\n## Execute a parameterized query\n```fs\nopen DustyTables\n\n// get the connection from the environment\nlet connectionString() = Env.getVar \"app_db\"\n\n// get product names by category\nlet productsByCategory (category: string) =\n    connectionString()\n    |\u003e Sql.connect\n    |\u003e Sql.query \"SELECT name FROM dbo.[Products] where category = @category\"\n    |\u003e Sql.parameters [ \"@category\", Sql.string category ]\n    |\u003e Sql.execute (fun read -\u003e read.string \"name\")\n```\n### Executing a stored procedure with parameters\n```fs\nopen DustyTables\n\n// get the connection from the environment\nlet connectionString() = Env.getVar \"app_db\"\n\n// check whether a user exists or not\nlet userExists (username: string) : bool =\n    connectionString()\n    |\u003e Sql.connect\n    |\u003e Sql.storedProcedure \"user_exists\"\n    |\u003e Sql.parameters [ \"@username\", Sql.string username ]\n    |\u003e Sql.executeRow (fun read -\u003e read.bool 0)\n```\n### Executing a stored procedure with table-valued parameters\n```fs\nopen DustyTables\nopen System.Data\n\n// get the connection from the environment\nlet connectionString() = Env.getVar \"app_db\"\n\nlet executeMyStoredProcedure () : Async\u003cint\u003e =\n    // create a table-valued parameter\n    let customSqlTypeName = \"MyCustomSqlTypeName\"\n    let dataTable = new DataTable()\n    dataTable.Columns.Add \"FirstName\" |\u003e ignore\n    dataTable.Columns.Add \"LastName\"  |\u003e ignore\n    // add rows to the table parameter\n    dataTable.Rows.Add(\"John\", \"Doe\") |\u003e ignore\n    dataTable.Rows.Add(\"Jane\", \"Doe\") |\u003e ignore\n    dataTable.Rows.Add(\"Fred\", \"Doe\") |\u003e ignore\n\n    connectionString()\n    |\u003e Sql.connect\n    |\u003e Sql.storedProcedure \"my_stored_proc\"\n    |\u003e Sql.parameters\n        [ \"@foo\", Sql.int 1\n          \"@people\", Sql.table (customSqlTypeName, dataTable) ]\n    |\u003e Sql.executeNonQueryAsync\n```\n\n## Building and running tests locally\n\nYou only need a working local SQL server. The tests will create databases when required and dispose them at the end of each test.\n\n```bash\ncd ./DustyTables.Build\n\n# Build the solution\ndotent run\n# Run the tests\ndotent run -- test\n# Publish the nuget\ndotnet run -- publish\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzaid-ajaj%2Fdustytables","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzaid-ajaj%2Fdustytables","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzaid-ajaj%2Fdustytables/lists"}