# New-SQLiteConnection

﻿

### New-SQLiteConnection <a href="#new-sqliteconnection" id="new-sqliteconnection"></a>

### SYNOPSIS <a href="#synopsis" id="synopsis"></a>

Creates a SQLiteConnection to a SQLite data source

### SYNTAX <a href="#syntax" id="syntax"></a>

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

### DESCRIPTION <a href="#description" id="description"></a>

Creates a SQLiteConnection to a SQLite data source

### EXAMPLES <a href="#examples" id="examples"></a>

#### EXAMPLE 1 <a href="#example-1" id="example-1"></a>

```
$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 <a href="#example-2" id="example-2"></a>

```
$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 <a href="#parameters" id="parameters"></a>

#### DataSource <a href="#datasource" id="datasource"></a>

```
-DataSource <String[]>
   SQLite Data Source to connect to.
   
   Required?                    true
   Position?                    1
   Default value                
   Accept pipeline input?       true (ByValue, ByPropertyName)
   Accept wildcard characters?  false
```

#### Password <a href="#password" id="password"></a>

```
-Password <SecureString>
   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.
   
   Required?                    false
   Position?                    3
   Default value                
   Accept pipeline input?       true (ByPropertyName)
   Accept wildcard characters?  false
```

#### ReadOnly <a href="#readonly" id="readonly"></a>

```
-ReadOnly [<SwitchParameter>]
   If specified, open SQLite data source as read only
   
   Required?                    false
   Position?                    4
   Default value                False
   Accept pipeline input?       true (ByPropertyName)
   Accept wildcard characters?  false
```

#### Open <a href="#open" id="open"></a>

```
-Open <Boolean>
   We open the connection by default.  You can use this parameter to create a connection without opening it.
   
   Required?                    false
   Position?                    5
   Default value                True
   Accept pipeline input?       true (ByPropertyName)
   Accept wildcard characters?  false
```

#### CommonParameters <a href="#commonparameters" id="commonparameters"></a>

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about\_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
