Coder Social home page Coder Social logo

abbgrade / pssmo Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 98 KB

The PowerShell SQL Client module replaces the SQL Server utilities SQLCMD with native PowerShell commands.

License: MIT License

PowerShell 50.91% C# 46.62% Dockerfile 2.47%
powershell sql-server automation sqlcmd azure-sql

pssmo's Introduction

PsSmo

The PowerShell SQL Client module replaces the SQL Server utilities SQLCMD with native PowerShell commands.

Installation

This module can be installed from PsGallery.

Install-Module -Name PsSmo -Scope CurrentUser

Alternatively it can be build and installed from source.

  1. Install the development dependencies
  2. Download or clone it from GitHub
  3. Run the installation task:
Invoke-Build Install

Usage

TODO

Execute SQLCMD scripts like those created by DacFX.

Commands

Command Description Status
Connect-Instance Create a new database connection.
Disconnect-Instance Close connection
Invoke-Command Execute SQLCMD scripts
⮱ Batch support Support GO statements
⮱ File support Script source from file
⮱ Variable support Support variables like $(variable)
⮱ :setvar support Support :setvar
⮱ SQLCMD command support Support SQLCMD commans like :on error
Uninstall-Schema Remove a database schema recursively

Changelog

See the changelog file.

Development

Status

.github/workflows/build-validation.yml

Build

The build scripts require InvokeBuild. If it is not installed, install it with the command Install-Module InvokeBuild -Scope CurrentUser.

You can build the module using the VS Code build task or with the command Invoke-Build Build.

Testing

The tests scripts are based on Pester. If it is not installed, install it with the command Install-Module -Name Pester -Force -SkipPublisherCheck. Some tests require a SQL Server. The test creates a SQL Server in a Docker container. If needed, install Docker. The container are created using PSDocker, which can be installed using Install-Module PSDocker -Scope CurrentUser.

For local testing use the VSCode test tasks or execute the test scripts directly or with Invoke-Pester. The InvokeBuild test tasks are for CI and do not generate console output.

Release

  1. Create a release branch using git-flow.
  2. Update the version number in the module manifest.
  3. Extend the changelog in this readme.
  4. If you want to create a pre-release.
    1. Push the release branch to github, to publish the pre-release to PsGallery.
  5. Finish release using git-flow.
  6. Check if tags are not pushed to github.
  7. Check if the release branch is deleted on github.
  8. Create the release on github.

pssmo's People

Contributors

abbgrade avatar dependabot[bot] avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

alicevik22

pssmo's Issues

Tests fail on Linux

The tests depend on localdb, which is currently only available on windows.

Connection timeout in windows build validation

Message:

Win32Exception: The wait operation timed out.
SqlException: Connection Timeout Expired. The timeout period elapsed while attempting to consume the pre-login handshake acknowledgement. This could be because the pre-login handshake failed or the server was unable to respond back in time. The duration spent while attempting to connect to this server was - [Pre-Login] initialization=80714; handshake=11;
at , D:\a\PsSmo\PsSmo\test\Connect-Instance.Tests.ps1:24

Token Refresh

In authentication with Azure, during the connect a token is created but never refreshed.
For long running sessions this will not work unless token refresh is implemented.

Delete schema

the should be a command to remove a SQL schema recursively with all it's tables etc.

Extract SQLCMD to own lib

The functions to interpret SQLCMD commands should be in a specialized library for reusability.
This may require a mapping from a .NET logging framework to the PowerShell logging approach.

Long-running SQL Scripts

Test and support long running scripts.
I looks like, scripts are terminated after 15 minutes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.