Git Product home page Git Product logo

invokesqlitequery's Introduction

InvokeSQLiteQuery

PowerShell Cmdlet to invoke a SQLite query to your SQLite database

PowerShell binary cmdlet Invoke-SQLiteQuery

  • Invoke-SQLiteQuery -Database /path/to/sqlite.db -Query "SELECT name FROM sqlite_master WHERE type='table';"

How to compile and start:

In PowerShell use the following commands to compile the cmdlet with .NET core:

dotnet publish -c Release
ipmo ./bin/Release/netstandard2.0/publish/InvokeSQLiteQuery.dll # Please note folder structure and sqlite3 lib below
Invoke-SQLiteQuery -Database /path/to/sqlite.db -Query "SELECT name FROM sqlite_master WHERE type='table';"

The Cmlet will give you the output from your SQLite query.

Installation from PowerShell Gallery (PSGallery)

You can download the module from PSGallery in PowerShell with this command:

Install-Module -Name InvokeSQLiteQuery

Folder structur of the Cmdlet

The files 'sqlite3.dll', 'libsqlite3.so' and 'libsqlite3.dylib' need to be copied from the 'runtimes' to the root folder. The folder structure should look like this:

InvokeSQLiteQuery
|--runtimes
   |--win7-x64
      |--native
         |--sqlite3.dll
   |--linux-x64
      |--[...]
InvokeSQLiteQuery.deps.json
InvokeSQLiteQuery.dll
InvokeSQLiteQuery.pdb
InvokeSQLiteQuery.psd1
libsqlite3.dylib
libsqlite3.so
Microsoft.CSharp.dll
Microsoft.Data.Sqlite.dll
Microsoft.EntityFrameworkCore.dll
Microsoft.EntityFrameworkCore.Relational.dll
Microsoft.EntityFrameworkCore.Sqlite.dll
Microsoft.Extensions.Caching.Abstractions.dll
Microsoft.Extensions.Caching.Memory.dll
Microsoft.Extensions.DependencyInjection.Abstractions.dll
Microsoft.Extensions.DependencyInjection.dll
Microsoft.Extensions.Logging.Abstractions.dll
Microsoft.Extensions.Logging.dll
Microsoft.Extensions.Options.dll
Microsoft.Extensions.Primitives.dll
Remotion.Linq.dll
sqlite3.dll
System.Collections.Immutable.dll
System.ComponentModel.Annotations.dll
System.ComponentModel.dll
System.Data.Common.dll
System.Diagnostics.DiagnosticSource.dll
System.Dynamic.Runtime.dll
System.Interactive.Async.dll
System.Linq.dll
System.Linq.Expressions.dll
System.Linq.Queryable.dll
System.Management.Automation.dll
System.ObjectModel.dll
System.Reflection.Emit.dll
System.Reflection.Emit.ILGeneration.dll
System.Reflection.Emit.Lightweight.dll
System.Reflection.TypeExtensions.dll
System.Runtime.CompilerServices.Unsafe.dll
System.Text.RegularExpressions.dll
System.Threading.dll

How to use Invoke-SQLiteQuery

Download Chinook database as a sample database SQLite. It is an new and cool alternative to the Northwind database and ideal for demos and testing with the Top of the Pops.

Show all columns in a SQLite table

Invoke-SQLiteQuery -Database "C:\Users\Public\Downloads\Chinook_Sqlite.sqlite" -Query "SELECT sql FROM sqlite_master WHERE type = 'table'"

Query the table Album

Invoke-SQLiteQuery -Database "C:\Users\Public\Downloads\Chinook_Sqlite.sqlite" -Query "SELECT AlbumId, Title, ArtistId FROM Album ORDER BY title LIMIT 10;"

Save result of a query to a CSV file

Invoke-SQLiteQuery -Database "C:\Users\Public\Downloads\Chinook_Sqlite.sqlite" -Query "SELECT AlbumId, Title, ArtistId FROM Album ORDER BY title LIMIT 10;" | ForEach-Object { $_ -join ','} | Out-File .\myfile.csv

Using an In-Memory database

Invoke-SQLiteQuery -Database ":memory:" -Query "SELECT 35 + 7;"

invokesqlitequery's People

Contributors

datenteiler avatar

Watchers

 avatar

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.