bin/SnsSqlitePsModule.xml
<?xml version="1.0"?>
<doc> <assembly> <name>SnsSqlitePsModule</name> </assembly> <members> <member name="T:SnsSqlitePsModule.BackupSnsSqliteDataBase"> <summary> <para type="synopsis"> Connects To A Specified SQLite DataBase Called Source DataBase Or Source For Short, Creates Another SQLite DataBase Called Destination Or Backup For Short, Connects To Destination DataBase And Copy The Whole Content From The Source Into The Destination DataBase. </para> <para type="description"> </para> <para type="description"> </para> <para type="description"> </para> <para type="description"> Connects To A Specified SQLite DataBase Called Source DataBase Or Source For Short, Creates Another SQLite DataBase Called Destination Or Backup For Short, Connects To Destination DataBase And Copy The Whole Content From The Source Into The Destination DataBase. </para> <para type="description"> Since The DataBase Backup Is Relatively Simple Process Initially I Had No Intention To Create Such CmdLet At All. However It Turned Out That It Requires Handling Of Multiple Exceptions. So This CmdLet Was Developed To Prevent The Exceptions Managing Over And Over Again. </para> <para type="description"> </para> <para type="description"> </para> <para type="description"> </para> <para type="description"> Before The Actual Backup The CmdLet Verifies The Source DataBase Existence And Whether Successful Writable (Not Read Only) Connection Can Be Established. Afterward The CmdLet Verifies The Backup File Existence, In Case It Exists Is Thrown Termination Error. In Case Force Switch Parameter Is Used The CmdLet Will Try To Delete The Destination DataBase File. Then New Blank Destination DataBase Is Created And It Is Verified Whether Writable Connection Can Be Established. In Case Both Connections Are Opened Successfully The CmdLet Performs Backup. </para> <para type="description"> Whenever The Destination DataBase Is Not Specified, The CmdLet Will Create The Backup DataBase In The Same Folder As The Source DataBase With Name The Same As The Source Prefixed With Digits Representing The Current UTC Date And Time. </para> <para type="description"> Whenever For Destination Is Specified A Folder, And That Folder Is Not The Folder Where The Source DataBase Is Located, The CmdLet Will Place The Backup DataBase Into The Specified Folder With Name Matching The Source DataBase Name. </para> <para type="description"> Whenever For Destination Is Specified Filename, The CmdLet Will Create The Backup DataBase With The Specified Name And Will Place It In The Current Working Folder. </para> <para type="description"> Whenever For Destination Is Specified Full Absolute File Path The Destination DataBase Will Be Created With The Specified Name In The Specified Location. </para> <para type="description"> </para> <para type="description"> </para> <para type="description"> </para> <list type="alertSet"> <item> <term> </term> <description> <para>AUTHOR: Svetoslav Nedyalkov Savov</para> <para>THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK</para> <para>OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.</para> <para></para> <para></para> <para></para> </description> </item> </list> <example> <code> Backup-SnsSqliteDataBase -DataBase "temp.db"; </code> <para> </para> <para> Backups DataBase "temp.db" Into A New DataBase Located In The Current Folder With The Same Name Prefixed With Digits Representing Current UTC Date And Time. </para> <para> </para> <para> </para> <para> </para> </example> <example> <code> Backup-SnsSqliteDataBase -DataBase "temp.db" -Destination "C:\Backups"; </code> <para> </para> <para> Backups DataBase "temp.db" Into "C:\Backup\temp.db". </para> <para> </para> <para> </para> <para> </para> </example> <example> <code> Backup-SnsSqliteDataBase -DataBase "temp.db" -Destination "backup.db"; </code> <para> </para> <para> Backups DataBase "temp.db" Into "backup.db" Both Located In The Current Working Folder. </para> <para> </para> <para> </para> <para> </para> </example> <example> <code> Backup-SnsSqliteDataBase -DataBase "temp.db" -Destination "C:\Backups\backup.db"; </code> <para> </para> <para> Backups DataBase "temp.db" Into "C:\Backups\backup.db". </para> <para> </para> <para> </para> <para> </para> </example> </summary> <para type="link" uri="https://github.com/svesavov/SnsSqlitePsModule"> svesavov / SnsSqlitePsModule - </para> <para type="link" uri="https://www.powershellgallery.com/packages/SnsSqlitePsModule/"> PowerShell Gallery - </para> <para type="link" uri="https://www.linkedin.com/in/svetoslavsavov"> Svetoslav Savov on LinkedIn - </para> <para type="link" uri="https://github.com/RamblingCookieMonster/PSSQLite"> RamblingCookieMonster / PSSQLite - </para> <para type="link" uri="https://sqlite.org/index.html"> SQLite V3 - </para> <para type="link" uri="https://www.sqlite.org/datatype3.html"> SQLite V3 Data Types - </para> <para type="link" uri="https://www.sqlite.org/lang.html"> SQLite V3 Supported SQL Syntax - </para> <para type="link" uri="http://www.sqlite.org/pragma.html"> SQLite V3 Pragma Statements - </para> <para type="link" uri="https://www.sqlitetutorial.net/"> SQLite V3 Tutorials - </para> <para type="link" uri="https://github.com/pawelsalawa/sqlitestudio/releases"> SQLite Studio - </para> </member> <member name="P:SnsSqlitePsModule.BackupSnsSqliteDataBase.DataBase"> <summary> <para type="description">Specifies SQLite DataBase File To Be Backed Up.</para> <para type="description">Accepts Either File Name Or Full Absolute UNC Path.</para> </summary> </member> <member name="P:SnsSqlitePsModule.BackupSnsSqliteDataBase.Destination"> <summary> <para type="description">Specifies The Backup File Or The Backup Folder.</para> <para type="description">Accepts Either File Name Or Full Absolute UNC Path.</para> <para type="description">If Not Provided The CmdLet Will Generate One Based On UTC Time And Source DataBase.</para> </summary> </member> <member name="P:SnsSqlitePsModule.BackupSnsSqliteDataBase.Force"> <summary> <para type="description">Specifies To Delete The Destination File Upfront If It Already Exists.</para> </summary> </member> <member name="P:SnsSqlitePsModule.BackupSnsSqliteDataBase.PassThru"> <summary> <para type="description">Specifies To Revert Output.</para> <para type="description">If Backup DataBase Size In Bytes Equals Source DataBase Will Revert The Backup FilePath.</para> <para type="description">If Backup DataBase Size In Bytes Not Equals Source DataBase Will String "Backup Failed".</para> </summary> </member> <member name="T:SnsSqlitePsModule.InvokeSnsSqliteObjectInsert"> <summary> <para type="synopsis"> Imports Collection Of Object Into Specified Table Within Specified SQLite DataBase. </para> <para type="description"> </para> <para type="description"> </para> <para type="description"> </para> <para type="description"> Imports Collection Of Object Into Specified Table Within Specified SQLite DataBase. </para> <para type="description"> This CmdLet Does Allow Users Without Or With Limited Knowledge About SQL Query Language To Work With DataBases. The CmdLet Creates The SQL Query And The SQL Parameters On Its Own. The User Has No Need Even To Know What SQL Injection Is And How To Avoid It. </para> <para type="description"> There Are Cases When We Have Large Collections Of Similar Objects That Corresponds Exactly To Specific Table In A DataBase And We Need To Insert Them At Once Taking The Advantage Of The SQL Transactions. This CmdLet Is Made Exactly For Those Cases. Like For Example We Need To Insert The Information About All Users In The Environment Into A DataBase Table Named Users. Then We Simply Query The Active Directory About All Users And Pipeline The Output To This CmdLet. </para> <para type="description"> </para> <para type="description"> </para> <para type="description"> </para> <para type="description"> The CmdLet Have Two ParameterSets Which Represent The Allowed Combination Of Input Parameters. </para> <para type="description"> Those ParameterSets Allows Either DataBase File To Be Specified Along With Parameters Used To Establish A Connection To It, Or To Be Specified SQLiteConnection Object Associated With An Existing Connection. The CmdLet Performs SQL INSERT Queries Therefore ReadOnly SQLConnection Is Not Allowed. </para> <para type="description"> The Specified Input Is Verified Either At The Parameters Section Or Within The Begin Method. Some Of The Input Is Verified Several Times With Various Verifications, As For Example The Table Name Is Verified Once Whether It Contains Non Alphanumeric Characters And Second Time Whether It Exists Inside The Specified DataBase. The CmdLet Can Handle INSERT Queries Only In Existing Data Sources With Existing Tables, Unlike The Rest Of The CmdLets Within This PowerShell Module Which Normally Would Create The Missing DataBase. </para> <para type="description"> The CmdLet Establishes SQL Connection At The Beginning Method And Query The DataBase About A List With The Existing Tables. In Case The Specified Table Exists It Query The DataBase Second Time About Tables Schema. The Retrieved Table Schema Is Used For The SQL Query Auto Initialization And The Enumeration Of The SQL Parameter Names. </para> <para type="description"> Because There Are Lot Faster Built Into SQLite Ways For Bulk Insert Data Within A Table, This CmdLet Most Likely Will Be Used In Automations Running On A Schedule. </para> <para type="description"> Whenever Initial Or One Time Data INSERT Is Required I Recommend The Manual Approach Using The Official SQLite Tools CLI https://www.sqlite.org/download.html Or SQLite Studio https://github.com/pawelsalawa/sqlitestudio/releases. Manual Approach Allows Greater Visibility. Using Graphical Interface For One Time Actions Is Always Better. </para> <para type="description"> To Avoid SQL Injection Issues The CmdLet Converts Each Of The Provided InputObjects To SQL Parameters And Auto Enumerates The SQL Query And Its SQL Variables From The Enumerated Table Columns. This Introduces Additional Requirements: </para> <para type="description"> - The Column Names In The Destination Table Must Contain Only Lower And Capital English Letters, Digits And Underscore (_) Character. </para> <para type="description"> - The Input Objects Property Names Must Match Exactly The Destination Table Column Names. </para> <para type="description"> - The Types Of The Values Inside The Input Objects Properties Must Match Exactly The Corresponding Destination Table Column Data Types. </para> <para type="description"> - The Values Inside The Input Objects Properties Must Be Normalized In Advance. </para> <para type="description"> </para> <para type="description"> - Whenever The Input Objects Have Properties Not Present In The Destination Table Schema, Their Values Will Be Ignored. </para> <para type="description"> - Whenever The Input Objects Have No Properties Present In The Destination Table Schema, The CmdLet Will Insert NULL In The Corresponding Columns. This Might Lead To SQL Errors Whenever Those Columns Have NOT NULL Constraint. </para> <para type="description"> Whenever Those Requirements Cannot Be Met The User Still Can Use Invoke-SnsSqliteQuery For Bulk Operations Which Does Provide More Control Over The Process But Requires More In-Depth SQL Query Language Knowledge. </para> <para type="description"> </para> <para type="description"> </para> <para type="description"> </para> <para type="description"> To Simplify The Dates Managing The Module Offers Predefined Formatting Strings To Convert DateTime Object To Understandable For SQLite Format. Although The CmdLet Will Process SQL Parameters Date Values Without Being Converted Upfront To Strings. </para> <para type="description"> Leaving The DateTime Objects To Be Automatically Managed Might Lead To Unexpected Results Related With The DateTime Syntax Coming From The Regional Settings On The Machine, Daylight Saving Related And TimeZone Related Issues. From That Perspective I Would Recommend The Dates To Be Normalized To Long Integer And To Be Stored In Numeric Columns. </para> <para type="description"> [System.DateTime]::Now.ToFileTime() - Gets The System DateTime And Converts It To Long Integer. </para> <para type="description"> [System.DateTime]::FromFileTime(108666144000000000) - Converts The Long Integer To Local DateTime With Time Zone And Daylight Saving Taken Into Consideration. </para> <para type="description"> [System.DateTime]::FromFileTimeUtc(108666144000000000) - Converts The Long Integer To Universal DateTime. (Guess What Is The Date From The Example). </para> <para type="description"> </para> <para type="description"> </para> <para type="description"> </para> <list type="alertSet"> <item> <term> </term> <description> <para>AUTHOR: Svetoslav Nedyalkov Savov</para> <para>THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK</para> <para>OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.</para> <para></para> <para></para> <para></para> </description> </item> </list> <example> <code> Invoke-SnsSqliteObjectInsert -DataBase "C:\temp.sqlite" -Table "MyTable" -InputObject $arrInputy; </code> <para> </para> <para> Converts The Specified InputObjects Collection To SQL Parameters And Insert The Data Into MyTable. </para> <para> </para> <para> </para> <para> </para> </example> <example> <code> $arrInput | Invoke-SnsSqliteObjectInsert -DataBase "C:\temp.sqlite" -Table "MyTable" -ConflictClause Replace; </code> <para> </para> <para> Converts The Pipelined InputObjects Collection To SQL Parameters And Insert The Data Into MyTable. </para> <para> </para> <para> In Case An Input Object Conflicts With Existing Entry, The Old One Will Be Replaced With The Data From The Input Object. </para> <para> </para> <para> </para> <para> </para> </example> </summary> <para type="link" uri="https://github.com/svesavov/SnsSqlitePsModule"> svesavov / SnsSqlitePsModule - </para> <para type="link" uri="https://www.powershellgallery.com/packages/SnsSqlitePsModule/"> PowerShell Gallery - </para> <para type="link" uri="https://www.linkedin.com/in/svetoslavsavov"> Svetoslav Savov on LinkedIn - </para> <para type="link" uri="https://github.com/RamblingCookieMonster/PSSQLite"> RamblingCookieMonster / PSSQLite - </para> <para type="link" uri="https://sqlite.org/index.html"> SQLite V3 - </para> <para type="link" uri="https://www.sqlite.org/datatype3.html"> SQLite V3 Data Types - </para> <para type="link" uri="https://www.sqlite.org/lang.html"> SQLite V3 Supported SQL Syntax - </para> <para type="link" uri="http://www.sqlite.org/pragma.html"> SQLite V3 Pragma Statements - </para> <para type="link" uri="https://www.sqlitetutorial.net/"> SQLite V3 Tutorials - </para> <para type="link" uri="https://github.com/pawelsalawa/sqlitestudio/releases"> SQLite Studio - </para> </member> <member name="P:SnsSqlitePsModule.InvokeSnsSqliteObjectInsert.DataBase"> <summary> <para type="description">Specifies SQLite DataBase File To Connect To.</para> <para type="description">The DataBase Must Exists, The CmdLet Won't Create It.</para> <para type="description">Accepts Either File Name Or Full Absolute UNC Paths.</para> </summary> </member> <member name="P:SnsSqlitePsModule.InvokeSnsSqliteObjectInsert.Connection"> <summary> <para type="description">Specifies Existing SQLite Connection.</para> <para type="description">In Case The Connection Is Not Open Or Expired The CmdLet Opens It.</para> </summary> </member> <member name="P:SnsSqlitePsModule.InvokeSnsSqliteObjectInsert.Table"> <summary> <para type="description">Specifies A Table Where The Data Will Be Inserted.</para> <para type="description">The Table Must Exist Inside The Specified DataBase, The CmdLet Won't Create It.</para> <para type="description">Allowed Characters In The Table Name Are: From a To z, From A To Z And _</para> </summary> </member> <member name="P:SnsSqlitePsModule.InvokeSnsSqliteObjectInsert.InputObject"> <summary> <para type="description">Specifies A Collection Of Input Objects To Be Inserted Into The DataBase Table.</para> <para type="description">Input Object Properties Must Be Struct Or String.</para> <para type="description">Input Object Properties Must Not Be Collections Or Other Classes.</para> </summary> </member> <member name="P:SnsSqlitePsModule.InvokeSnsSqliteObjectInsert.ConflictClause"> <summary> <para type="description">Specifies A Conflict Clause To Use In Case A Conflict Occurs During Insert.</para> <para type="description">See https://www.sqlite.org/lang_conflict.html for more details.</para> <para type="description">Accepted Values: "Rollback", "Abort", "Fail", "Ignore" And "Replace"</para> </summary> </member> <member name="P:SnsSqlitePsModule.InvokeSnsSqliteObjectInsert.QueryTimeout"> <summary> <para type="description">Specifies The Number Of Seconds Before The Query Times Out.</para> </summary> </member> <member name="T:SnsSqlitePsModule.InvokeSnsSqliteQuery"> <summary> <para type="synopsis"> Connects To A Specified SQLite DataBase, Executes SQL Query / Queries Against The DataBase, Reverts The Output In A Collection Of Specified DataType And Closes The SQL Session. </para> <para type="description"> </para> <para type="description"> </para> <para type="description"> </para> <para type="description"> Connects To A Specified SQLite DataBase, Executes SQL Query / Queries Against The DataBase, Reverts The Output In A Collection Of Specified DataType And Closes The SQL Session. </para> <para type="description"> The CmdLet Is Based On Warren Frame's (RamblingCookieMonster) And His Contributors Project Named "PSSQLite". More Details Can Be Found In The Links In The Link Section Below. </para> <para type="description"> </para> <para type="description"> </para> <para type="description"> </para> <para type="description"> Like The Original CmdLet The Input Is Validated At The Beginning Within The Parameter Definitions. For That Purpose Custom Validation Attributes Were Developed, Since "[ValidateScript({})]" Validation Attribute Is Not Supported In C#. </para> <para type="description"> The CmdLet Is Capable To Connect To The Specified SQLite DataBase / DataSource By Itself. There Is No Requirement SQLiteConnection To Be Established In Advance. In The Begin Method The CmdLet Evaluate The Provided Input And In Case DataBase Is Provided, The CmdLet Verifies The DataBase File Existence And If Needed Creates The DataBase File. For Some Reason Automatic DataBase File Creation Does Not Work In C#. Whenever A New DataBase Is Created, The User Is Notified With A Warning Message. </para> <para type="description"> The Connection Is Established Once In The Begin Method. All The Specified Queries Are Sent In The Process Method. Therefore All The Queries Are Sent Over A Single Already Created And Verified Connection. </para> <para type="description"> The CmdLet Will Execute All The Specified SQL Queries Or Single Query With Multiple Parameters Using A SQL Transaction. Because The Transaction Have To Be Started Before The First Query And The Queries Can Be Provided Via The Pipeline, The CmdLet Will Evaluate Only The First Provided Query. This Might Lead To Unexpected Behavior Whenever The First Provided Query Allows Transactions Usage And The Consequent Once Do Not. Then The SQLite Will Throw Errors And The Whole Transaction Will Be Reverted Even Though The First Queries Are Successful. The CmdLet Will Auto Create A Transaction When: </para> <para type="description"> -- The Specified SQL Connection Is Not ReadOnly. </para> <para type="description"> -- ReadOnly Parameter Of The CmdLet Is Not Specified Or It Is Explicitly Specified FALSE. </para> <para type="description"> -- The First SQL Query Contains Neither "VACUUM" Nor "PRAGMA" Nor "COMMIT". "VACUUM" And "PRAGMA" Cannot Be Used In Transactions. Attempting To Do So Will Throw SQLite Error. "COMMIT" Keyword Is Used In The SQL Language To Commit Previously Created Transaction. In That Case It Is Assumed That The User Manages The Transactions By Himself Within The SQL Query And New Transaction Is Not Auto Created. </para> <para type="description"> -- The First Query Contains Either "INSERT" Or "UPDATE" Statements. If We Nod Modify The Data Within The DataBase We In Fact Do Not Need DataBase Locks And Transaction Will Provide No Benefits, Rather Downsides Because It Prevents Other Clients To Modify That Data At That Time. </para> <para type="description"> Whenever The Specified DataBase Doesn't Exist And ReadOnly Parameter Value Is TRUE, The CmdLet Will Override The Users Input And The DataBase Will Be Created And Opened In Write Mode. </para> <para type="description"> Whenever The SQL Query Which Needs To Be Run Against The DataBase Is Too Complex Can Be Used SQL Query Input File. The CmdLet Does Allow Usage Of SQL Query File With Standard ".SQL" Extension With Specifying Of SQL Parameters As HashTable, However It Does Not Support Usage Of Multiple ".SQL" Files At Once. It Still Can Be Used To Import Single SQL Query And Using Of Collection Of SQL Parameter Dictionaries To Insert Multiple Rows At Once. The ".SQL" File Read Happens In Begin Method, Which Exclude The Possibility To Execute Multiple SQL Queries At Once. I Don't Want File Operations In Process Method Because Of Performance Considerations. </para> <para type="description"> </para> <para type="description"> </para> <para type="description"> </para> <para type="description"> The CmdLet Have Four ParameterSets Which Represent The Allowed Combination Of Input Parameters. </para> <para type="description"> The CmdLet Parameters And Pipeline Were Redesigned, Because For Me Makes More Sense To Use The Pipeline For Sending SQL Queries And SQL Parameters Rather Than Sending DataBase Sources. In My Automation Scripts I Mostly Use Multiple Queries And Parameters Run Against Single DataBase Rather Than Simultaneously Run The Same Query With The Same Parameters Against Multiple DataBases. If I Ever Need High Availability On My Automations Would Prefer To Schedule Them To Run On A Virtual Machine Which Is A Resource On ESX Or Other Virtualization Platform Which Allows The Virtual Machine To Be Replicated And Powered On Different Host Machines Rather Than Writing Of A Script Capable To Jump From One Machine To Another. With The New Parameters And Pipeline Design The CmdLet Can: </para> <para type="description"> - Runs Single SQL Query Without Any SQL Parameters HashTable. Provided Directly To The Parameters Or As Object Property Of An Object Coming From The Pipeline. Using This Option Is Not Desirable Whenever Within The Query We Have Users Input Because Of SQL Injection Risk. </para> <para type="description"> - Single SQL Query And Single SQL Parameters HashTable, Provided Directly To The Parameters Or Via The Pipeline. Here Are Possible Two Combinations: The Query And The Parameter As Properties Of An Object Coming From The Pipeline Or The SQL Parameters HashTable Coming From The Pipeline And Query Specified As A Parameter. </para> <para type="description"> - Single SQL Query And Collection Of SQL Parameters HashTables. In This Case The Parameters Represents Multiple Rows Which Have To Be Inserted Within Single Table. The User Have To Keep In Mind That The SQL Query Must Have SQL Variables For Each Of The Columns And Each HashTable In The Collections Have To Have Keys Corresponding To Each Of The SQL Variables. The SQL Query And Its Corresponding HashTables Collection Can Be Specified Either Directly To The Parameters, Or Via As Properties Of An Object Coming From Pipeline Or Specifying The Query To The CmdLet Query Parameter And The HashTables Collection Coming From The Pipeline. </para> <para type="description"> The CmdLet Is Still Capable To Work With Collection Of SQL Queries, However The Queries And Their Corresponding SQL Parameters HashTable / HashTables If Any, Can Be Provided Only Within Properties Of Objects Collection Coming From The Pipeline. Single Object Coming From The Pipeline Cannot Have Multiple SQL Queries. </para> <para type="description"> </para> <para type="description"> </para> <para type="description"> </para> <para type="description"> To Simplify The Dates Managing The Module Offers Predefined Formatting Strings To Convert DateTime Object To Understandable For SQLite Format. Although The CmdLet Will Process SQL Parameters Date Values Without Being Converted Upfront To Strings. </para> <para type="description"> Leaving The DateTime Objects To Be Automatically Managed Might Lead To Unexpected Results Related With The DateTime Syntax Coming From The Regional Settings On The Machine, Daylight Saving Related And TimeZone Related Issues. From That Perspective I Would Recommend The Dates To Be Normalized To Long Integer And To Be Stored In Numeric Columns. </para> <para type="description"> [System.DateTime]::Now.ToFileTime() - Gets The System DateTime And Converts It To Long Integer. </para> <para type="description"> [System.DateTime]::FromFileTime(108666144000000000) - Converts The Long Integer To Local DateTime With Time Zone And Daylight Saving Taken Into Consideration. </para> <para type="description"> [System.DateTime]::FromFileTimeUtc(108666144000000000) - Converts The Long Integer To Universal DateTime. (Guess What Is The Date From The Example). </para> <para type="description"> </para> <para type="description"> </para> <para type="description"> </para> <list type="alertSet"> <item> <term> </term> <description> <para>AUTHOR: Svetoslav Nedyalkov Savov</para> <para>THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK</para> <para>OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.</para> <para></para> <para></para> <para></para> </description> </item> </list> <example> <code> Invoke-SnsSqliteQuery -DataBase "temp.sqlite" ` -Query "CREATE TABLE Events (ID INTEGER, ComputerID INTEGER, Event VARCHAR(20), Date DATETIME)"; </code> <para> </para> <para> Creates A Table "Events" And "temp.sqlite" DataBase If It Does Not Exists. </para> <para> </para> <para> </para> <para> </para> </example> <example> <code> Invoke-SnsSqliteQuery -DataBase "temp.sqlite" ` -Query "INSERT INTO Events (ID, ComputerID, Event, Date) VALUES (@ID, @ComputerID, @Event, @Date);" ` -SqlParameters ` @{ "@ID" = 1; "@ComputerID" = 5 "Event" = "Error"; "Date" = [System.DateTime]::Now); }; </code> <para> </para> <para> Runs Single Query With Single SQL Parameters HashTable Against "temp.sqlite" DataBase. </para> <para> In The SQL Parameters Keys Are Used Both Strings With And Without At (@) Character. </para> <para> </para> <para> The Keys Match Exactly The SQL Query Variables. Please Note That There Are SQL Variables For Each Of The Columns. </para> <para> </para> <para> </para> <para> </para> </example> <example> <code> Invoke-SnsSqliteQuery -DataBase "temp.sqlite" ` -Query "INSERT INTO Computers (ID, HostName) VALUES (@ID, @HostName);" ` -SqlParameters ` @( @{"@ID" = 1; "HostName" = "Computer1.contoso.com"; }; @{"@ID" = 2; "HostName" = "Computer2.contoso.com"; }; ); </code> <para> </para> <para> Runs Single Query With Multiple SQL Parameters HashTables Against "temp.sqlite" DataBase. </para> <para> In The SQL Parameters Keys Are Used Both Strings With And Without At (@) Character. </para> <para> </para> <para> The Keys Match Exactly The SQL Query Variables. Please Note That There Are SQL Variables For Each Of The Columns. </para> <para> </para> <para> </para> <para> </para> </example> </summary> <para type="link" uri="https://github.com/svesavov/SnsSqlitePsModule"> svesavov / SnsSqlitePsModule - </para> <para type="link" uri="https://www.powershellgallery.com/packages/SnsSqlitePsModule/"> PowerShell Gallery - </para> <para type="link" uri="https://www.linkedin.com/in/svetoslavsavov"> Svetoslav Savov on LinkedIn - </para> <para type="link" uri="https://github.com/RamblingCookieMonster/PSSQLite"> RamblingCookieMonster / PSSQLite - </para> <para type="link" uri="https://sqlite.org/index.html"> SQLite V3 - </para> <para type="link" uri="https://www.sqlite.org/datatype3.html"> SQLite V3 Data Types - </para> <para type="link" uri="https://www.sqlite.org/lang.html"> SQLite V3 Supported SQL Syntax - </para> <para type="link" uri="http://www.sqlite.org/pragma.html"> SQLite V3 Pragma Statements - </para> <para type="link" uri="https://www.sqlitetutorial.net/"> SQLite V3 Tutorials - </para> <para type="link" uri="https://github.com/pawelsalawa/sqlitestudio/releases"> SQLite Studio - </para> </member> <member name="P:SnsSqlitePsModule.InvokeSnsSqliteQuery.DataBase"> <summary> <para type="description">Specifies SQLite DataBase File To Connect To.</para> <para type="description">In Case DataBase Doesn't Exist The CmdLet Creates It And Throw Warning.</para> <para type="description">Accepts Either File Name Or Full Absolute UNC Paths.</para> </summary> </member> <member name="P:SnsSqlitePsModule.InvokeSnsSqliteQuery.ReadOnly"> <summary> <para type="description">Specifies To Open The DataBase In ReadOnly Mode.</para> </summary> </member> <member name="P:SnsSqlitePsModule.InvokeSnsSqliteQuery.Connection"> <summary> <para type="description">Specifies Existing SQLite Connection.</para> <para type="description">In Case The Connection Is Not Open Or Expired The CmdLet Opens It.</para> </summary> </member> <member name="P:SnsSqlitePsModule.InvokeSnsSqliteQuery.Query"> <summary> <para type="description">Specifies The SQL Query To Be Run.</para> </summary> </member> <member name="P:SnsSqlitePsModule.InvokeSnsSqliteQuery.InputFile"> <summary> <para type="description">Specifies A ".SQL" File To Be Used As Query Input.</para> <para type="description">Works Only With Full Absolute UNC Path To The File.</para> </summary> </member> <member name="P:SnsSqlitePsModule.InvokeSnsSqliteQuery.SqlParameters"> <summary> <para type="description">HashTable Of Parameters For Parameterized SQL Queries.</para> <para type="description">The HashTable Keys Must Match The SQL Query Variable Names.</para> <para type="description">The Keys Might Be Specified Either With Or Without At (@) Character In Front.</para> <para type="description">The CmdLet Will Take Care To Add Them If Missing.</para> <para type="description">Example:</para> <para type="description">-Query "SELECT * FROM tblServers WHERE ServerFqdn LIKE @Server"</para> <para type="description">-SqlParameters @{"@Server" = "Server01.contoso.com"}</para> </summary> </member> <member name="P:SnsSqlitePsModule.InvokeSnsSqliteQuery.QueryTimeout"> <summary> <para type="description">Specifies The Number Of Seconds Before The Query Times Out.</para> </summary> </member> <member name="P:SnsSqlitePsModule.InvokeSnsSqliteQuery.As"> <summary> <para type="description">Specifies To The CmdLet To Revert The Output In One Of The Following Types:</para> <para type="description">[System.Data.DataSet]</para> <para type="description">[System.Data.DataTable[]]</para> <para type="description">[System.Data.DataRow[]]</para> <para type="description">[System.Management.Automation.PSCustomObject[]]</para> </summary> </member> <member name="P:SnsSqlitePsModule.InvokeSnsSqliteQuery.AppendDataSource"> <summary> <para type="description">Specifies To Append The SQLite DataBase Path To The Output.</para> </summary> </member> <member name="T:SnsSqlitePsModule.NewSnsSqliteConnection"> <summary> <para type="synopsis"> Initializes And Reverts A SQLiteConnection Object. </para> <para type="description"> Initializes And Reverts A SQLiteConnection Object. </para> <para type="description"> If The Specified DataBase Doesn't Exist, The CmdLet Throw A Warning And Creates The DataBase. When This Happen And ReadOnly Mode Is Requested, The CmdLet Will Ignore Users Input And Will Establish The Connection To The Newly Created DataBase In Read Write Mode. If Read Only Connections To Multiple DataBases Are Needed And Only One Of Those DataBases Doesn't Exist, Only That Connection Will Be In Read Write Mode And The Remaining Will Be In Read Only Mode. </para> <para type="description"> By Default The CmdLet Establish The Connection To The Specified DataBase With Opening Of A Session, However Using Open Parameter It Can Create The SQLiteConnection Object Without Opening Of Session. </para> <list type="alertSet"> <item> <term> </term> <description> <para>AUTHOR: Svetoslav Nedyalkov Savov</para> <para>THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK</para> <para>OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.</para> <para></para> <para></para> <para></para> </description> </item> </list> <example> <code> [System.Data.SQLite.SQLiteConnection]$objConn = New-SnsSqliteConnection -DataBase "C:\TempDB\temp.sqlite" ` -Open:$false; </code> <para> </para> <para> Creates Connection To A DataBase Located In The Specified Folder Without Opening Of The Session. </para> <para> If The DataBase File Doesn't Exist In The Specified Folder, Creates The DataBase. Then Creates Connection To The DataBase Without Opening Of The Session. </para> <para> </para> <para> </para> <para> </para> </example> <example> <code> [System.Data.SQLite.SQLiteConnection]$objConn = New-SnsSqliteConnection -DataBase "temp.sqlite"; </code> <para> </para> <para> Creates And Opens A Connection To A DataBase Located In The Working Folder. </para> <para> If The DataBase File Doesn't Exist In The Current Working Folder, Creates It. Then Creates And Opens A Connection To The DataBase. </para> <para> </para> <para> </para> <para> </para> </example> <example> <code> $objProdConn, $objBackupConn = New-SnsSqliteConnection -DataBase "temp.sqlite", "Backup.sqlite" -ReadOnly; </code> <para> </para> <para> Creates And Opens A Connection To "temp.sqlite" DataBase Located In The Working Folder In ReadOnly Mode. For The Purpose Of The Example It Needs To Be Existing DataBase File With Data Inside. </para> <para> For The Purpose Of The Example DataBase "Backup.sqlite" Is Not Existing DataBase. In That Case DataBase "Backup.sqlite" Is Created, And Because It Is New DataBase The Output Connection Object Is In "Modify" Mode. </para> <para> </para> <para> </para> <para> </para> <code> $objProdConn.BackupDatabase($objBackupConn, "main", "main", -1, $null, 0); </code> <para> </para> <para> Backups All The Data From Production DataBase To The Backup One. This Way With Two Lines Of Code We Can Create New DataBase And Copy/Backup All The Data From An Existing To The New DataBase. </para> <para> </para> <para> </para> <para> </para> </example> </summary> <para type="link" uri="https://github.com/svesavov/SnsSqlitePsModule"> svesavov / SnsSqlitePsModule - </para> <para type="link" uri="https://www.powershellgallery.com/packages/SnsSqlitePsModule/"> PowerShell Gallery - </para> <para type="link" uri="https://www.linkedin.com/in/svetoslavsavov"> Svetoslav Savov on LinkedIn - </para> <para type="link" uri="https://github.com/RamblingCookieMonster/PSSQLite"> RamblingCookieMonster / PSSQLite - </para> <para type="link" uri="https://sqlite.org/index.html"> SQLite V3 - </para> <para type="link" uri="https://www.sqlite.org/datatype3.html"> SQLite V3 Data Types - </para> <para type="link" uri="https://www.sqlite.org/lang.html"> SQLite V3 Supported SQL Syntax - </para> <para type="link" uri="http://www.sqlite.org/pragma.html"> SQLite V3 Pragma Statements - </para> <para type="link" uri="https://www.sqlitetutorial.net/"> SQLite V3 Tutorials - </para> <para type="link" uri="https://github.com/pawelsalawa/sqlitestudio/releases"> SQLite Studio - </para> </member> <member name="P:SnsSqlitePsModule.NewSnsSqliteConnection.DataBase"> <summary> <para type="description">Specifies SQLite DataBase File To Connect To.</para> <para type="description">In Case DataBase Doesn't Exist The CmdLet Creates It And Generates Warning.</para> <para type="description">Accepts Either File Name Or Full Absolute UNC Paths.</para> </summary> </member> <member name="P:SnsSqlitePsModule.NewSnsSqliteConnection.ReadOnly"> <summary> <para type="description">Specifies To Open The DataBase In ReadOnly Mode.</para> </summary> </member> <member name="P:SnsSqlitePsModule.NewSnsSqliteConnection.Open"> <summary> <para type="description">Specifies To Open The SQL Connection.</para> <para type="description">Connection Is Opened By Default. Used To Create A Connection Without Opening It.</para> </summary> </member> </members> </doc> |