dbops v0.5 – new features

Yet another release of dbops Powershell module is finally out in the wild! A fresh v0.5.1 version is available now and can be downloaded from PSGallery and GitHub. A brief list of features:

  • MySQL support
  • PostgreSQL support
  • Cross-platform ad-hoc query command: Invoke-DBOQuery
  • Full Linux & PS Core support
    • Compatible with .Net Standard 2.0
    • Module is now tested on both Windows and Linux
  • Missing connectivity libraries can now be downloaded and installed interactively
  • Core deployment libraries – DbUp – were upgraded to v.4.2.0
  • Hundreds of new tests for every supported RDBMS:
    • SQL Server
    • Oracle
    • MySQL
    • PostgreSQL
  • New connection string parser to support all database types that allows for deep customization

Ad-hoc queries via Invoke-DBOQuery

New function Invoke-DBOQuery provides a cross-platform querying experience for all four supported RDBMS. Some of the most notable features:

  • Highly customizable connection parameters
  • Running queries from files or variables
  • JSON configuration files and native dbops configs are supported
  • Interactive console: -Interactive (or simply -i)

Some real-life examples:

# Get current database from a PostgreSQL server
Invoke-DBOQuery -Type PostgreSQL -Server localhost:5432 -Database postgres -Query 'SELECT current_database()' -As SingleValue
# Run a query against MySQL database
Invoke-DBOQuery -Type MySQL -Server localhost -Database mysql -Query 'SELECT Name from Users'
# Run multiple files from a folder in a specific SQL Server database
Get-ChildItem .\Scripts | Invoke-DBOQuery -SqlInstance 'SqlServer1:1443' -Database MyDB
# Connect to an Oracle database interactively as SYSDBA
Invoke-DBOQuery -Type Oracle -SqlInstance localhost -Interactive -Username sys -Password $mySecurePassword -ConnectionAttribute @{ 'DBA Privilege' = 'SYSDBA' }

MySQL and PostgreSQL support

The module now fully supports interactions with MySQL and PostgreSQL, as well as continues to support SQL Server and Oracle. You can choose which connection library to use by specifying the -Type parameter.

# install a DBOps package to the MySQL server
Install-DBOPackage Type MySQL Server localhost Database mydb Path .\package.zip
# invoke a query against a remote PostgreSQL server
Invoke-DBOQuery Type PostgreSQL SqlInstance pgsql1:5432 Database mydb Query 'SELECT current_database();'
# change the default connection -Type (SQLServer) to PostgreSQL:
Set-DBODefaultSetting Name rdbms.type Value 'PostgreSQL'

Linux & PS Core support

The module is fully compatible with Linux (and probably MacOS? I have no way to verify) and can be used on Powershell Core 6.1 and higher.

All the existing unit and integration tests now run on both Linux and Windows.