Gz-Db
0.1.0
# Gz-Db Module
Database agnostic Powershell functions over ADO.NET.
The primary functions are Invoke-GzDbCommand, Read-GzDbData, and Write-GzDbData. If
a connection or connectionString is not provided to the functions, the functions
will attempt to use the default connection set by Set-GzDbConnectionString.
Any function that has a `-Do` parameter, can be
# Gz-Db Module
Database agnostic Powershell functions over ADO.NET.
The primary functions are Invoke-GzDbCommand, Read-GzDbData, and Write-GzDbData. If
a connection or connectionString is not provided to the functions, the functions
will attempt to use the default connection set by Set-GzDbConnectionString.
Any function that has a `-Do` parameter, can be passed a script block that will
have the `$_` context variable set with either the connection or command object.
Sqlite is bundled with module. To switch the default provider use:
```powershell
Set-GzDbProviderFactoryDefault "Sqlite"
```
## Examples
- Set-GzDbConnectionString - sets the default or a named connection string.
- New-GzDbConnection - creates a new connection
- Write-GzDbData - inserts or updates data in the database.
- Read-GzDbData - reads data from the database.
- Invoke-GzDbCommand - executes a statement such as create database or grants.
```powershell
Set-GzDbConnectionString "Server=localhost;Database=test;Integrate Security=true" -Name "Default"
# uses the default connection string set above
$data = Read-GzDbData "SELECT name FROM [users]"
Write-Host $data
# control the connection
$connection = New-GzDbConnection -ConnectionString $cs
$connection.Open()
$emails = $connection | Read-GzDbData "SELECT email FROM [users]"
$connection | Write-GzDbData "INSERT [name] INTO [user_roles] ([name], [role]) VALUES (@name, 1)" -Parameters @{name = "test"}
$connection.Dispose()
# opens and closes the connection
# autocreates a `$Connection` variable
# returns any output.
$data = New-GzDbConnection -Do {
return $Connection | Read-GzDbData "SELECT email FROM [users]"
}
```
## Gz Prefix
The Gz prefix exists to clobbering.
Add-GzDbAlias will set aliases that map to GzDb functions .e.g. Invoke-DbCommand
will be mapped to Invoke-GzDbCommand.
Minimum PowerShell version
5.1
Installation Options
Owners
Copyright
(c) 2017-2019 Nerdy Mishka, Michael Herndon. All rights reserved.
Package Details
Author(s)
- Nerdy Mishka Michael Herndon
Tags
SQL ADO.NET ado Db Query Database SqlClient Gainz Gz Gainz-SqlDb Windows Mac Linux
Functions
Add-GzDbAlias Add-GzDbProviderFactory Get-GzDbOption Set-GzDbOption Set-GzDbConnectionString Get-GzDbConnectionString New-GzDbProviderFactory Set-GzDbProviderFactory Get-GzDbProviderFactory Get-GzDbParameterPrefix Set-GzDbParameterPrefix New-GzDbConnection New-GzDbCommand Read-GzDbData Write-GzDbData Invoke-GzDbCommand Remove-GzDbAlias
PSEditions
Dependencies
This module has no dependencies.
Release Notes
- 0.1.0 -- Early Release.
FileList
- Gz-Db.nuspec
- Gz-Db.psd1
- Gz-Db.psm1
- LICENSE
- README.md
- bin\SQLite.Interop.dll
- bin\System.Data.SQLite.dll
- bin\System.Data.SQLite.dll.config
- bin\System.Data.SQLite.xml
- bin\runtimes\linux-x64\SQLite.Interop.dll
- bin\runtimes\osx-x64\SQLite.Interop.dll
- bin\runtimes\win-x64\SQLite.Interop.dll
- bin\runtimes\win-x86\SQLite.Interop.dll
- public\Add-GzDbAlias.ps1
- public\Add-GzDbParameter.ps1
- public\Add-GzDbProviderFactory.ps1
- public\Get-GzDbConnectionString.ps1
- public\Get-GzDbOption.ps1
- public\Get-GzDbParameterPrefix.ps1
- public\Get-GzDbProviderFactory.ps1
- public\Invoke-GzDbCommand.ps1
- public\New-GzDbCommand.ps1
- public\New-GzDbConnection.ps1
- public\New-GzDbProviderFactory.ps1
- public\New-GzSqlClientParameter.ps1
- public\Read-GzDbData.ps1
- public\Set-GzDbConnectionString.ps1
- public\Set-GzDbProviderFactoryDefault.ps1
- public\Write-GzDbData.ps1
Version History
Version | Downloads | Last updated |
---|---|---|
0.1.0 (current version) | 5,395 | 3/17/2019 |