Skip to content

New-SQLiteConnection

SYNOPSIS

Creates a SQLiteConnection to a SQLite data source

SYNTAX

New-SQLiteConnection [-DataSource] <String[]> [[-Password] <SecureString>] [-ReadOnly] [[-Open] <Boolean>]
 [<CommonParameters>]

DESCRIPTION

Creates a SQLiteConnection to a SQLite data source

EXAMPLES

EXAMPLE 1

$Connection = New-SQLiteConnection -DataSource C:\NAMES.SQLite
Invoke-SQLiteQuery -SQLiteConnection $Connection -query $Query

Connect to C:\NAMES.SQLite, invoke a query against it

EXAMPLE 2

$Connection = New-SQLiteConnection -DataSource :MEMORY: 
Invoke-SqliteQuery -SQLiteConnection $Connection -Query "CREATE TABLE OrdersToNames (OrderID INT PRIMARY KEY, fullname TEXT);"
Invoke-SqliteQuery -SQLiteConnection $Connection -Query "INSERT INTO OrdersToNames (OrderID, fullname) VALUES (1,'Cookie Monster');"
Invoke-SqliteQuery -SQLiteConnection $Connection -Query "PRAGMA STATS"

Create a connection to a SQLite data source in memory

Create a table in the memory based datasource, verify it exists with PRAGMA STATS

$Connection.Close() $Connection.Open() Invoke-SqliteQuery -SQLiteConnection $Connection -Query "PRAGMA STATS"

Close the connection, open it back up, verify that the ephemeral data no longer exists

PARAMETERS

-DataSource

SQLite Data Source to connect to.

Type: System.String[]
Parameter Sets: (All)
Aliases: Instance, Instances, ServerInstance, Server, Servers, cn, Path, File, FullName, Database

Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False

-Password

Specifies A Secure String password to use in the SQLite connection string.

SECURITY NOTE: If you use the -Debug switch, the connectionstring including plain text password will be sent to the debug stream.

Type: System.Security.SecureString
Parameter Sets: (All)
Aliases:

Required: False
Position: 3
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False

-ReadOnly

If specified, open SQLite data source as read only

Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: 4
Default value: False
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False

-Open

We open the connection by default. You can use this parameter to create a connection without opening it.

Type: System.Boolean
Parameter Sets: (All)
Aliases:

Required: False
Position: 5
Default value: True
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

System.Data.SQLite.SQLiteConnection

NOTES

https://github.com/RamblingCookieMonster/Invoke-SQLiteQuery

Invoke-SQLiteQuery

Back to top