https://github.com/adamdriscoll/psdapper
Easy to use PowerShell module for working with SQL via Dapper.
https://github.com/adamdriscoll/psdapper
sql
Last synced: 26 days ago
JSON representation
Easy to use PowerShell module for working with SQL via Dapper.
- Host: GitHub
- URL: https://github.com/adamdriscoll/psdapper
- Owner: adamdriscoll
- Created: 2025-11-01T03:34:41.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-11-01T16:16:06.000Z (8 months ago)
- Last Synced: 2026-01-24T01:40:08.704Z (5 months ago)
- Topics: sql
- Language: PowerShell
- Homepage:
- Size: 15.6 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# PSDapper PowerShell Module
An extremely easy to use PowerShell module for working with SQL databases using Dapper. Provides easy commands for creating connections, selecting data, and executing SQL commands with minimal dependencies.
## Installation
```powershell
Install-PSResource -Name PSDapper -Repository PSGallery
```
## Commands
### New-DapperConnection
Creates and opens a SQL connection.
**Usage:**
```powershell
$connection = New-DapperConnection -ConnectionString "Server=.;Database=Test;Trusted_Connection=True;"
```
### Select-DapperObject
Executes a SQL SELECT query and returns results.
**Usage:**
```powershell
Select-DapperObject -Connection $connection -Query "SELECT * FROM Users WHERE Id = @Id" -Parameters @{ Id = 1 }
```
### Invoke-DapperSqlCommand
Executes a SQL command (INSERT, UPDATE, DELETE) and returns the number of affected rows.
**Usage:**
```powershell
Invoke-DapperCommand -Connection $connection -Command "UPDATE Users SET Name = @Name WHERE Id = @Id" -Parameters @{ Name = 'John'; Id = 1 }
```
## Error Handling
All commands provide meaningful error messages if something goes wrong.
## Help
Each command includes built-in help. Use `Get-Help ` for details and examples.
## Testing
Pester unit tests are recommended for validating command functionality.
---