bin/SnsSqlitePsModule.xml
<?xml version="1.0"?>
<doc> <assembly> <name>SnsSqlitePsModule</name> </assembly> <members> <member name="T:SnsSqlitePsModule.BackupSnsSqliteDataBase"> <summary> <para type="synopsis"> This Cmdlet Connect To A Specified SQLite DataBase Called 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"> This Cmdlet Connect To A Specified SQLite DataBase Called 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 Many Exceptions. So This CmdLet Was Developed To Prevent The Exceptions Handling 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 (svesavov@hotmail.com)</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> Backup 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> Backup 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> Backup 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> Backup 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.Password"> <summary> <para type="description">Specifies A [System.Security.SecureString] Or [System.String] Password For The Backup Source.</para> <para type="description">The Destination DataBase Will Be Created With The Same Password.</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"> This Cmdlet 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"> This Cmdlet 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"> The CmdLet Have Two ParameterSets Which Represent The Allowed Combination Of Input Parameters. </para> <para type="description"> Those ParametersSets Allows Either DataBase File To Be Specified With Parameters Used To Establish A Connection To It, Or To Be Specified SQLiteConnection Object For Existing Connection. As Long As The CmdLet Performs SQL INSERT Queries It Is Not Allowed The SQLConnection To Be Established In ReadOnly Mode. </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 Components. </para> <para type="description"> The CmdLet Establishes SQL Connection At The Beginning Method And Query The DataBase About For A List Of Existing Tables And In Case The Table Exists It Query The DataBase Second Time About Tables Schema. The Retrieved Table Schema Is Used For The SQL Query Generation And The SQL Parameter Names Which Will Be Used Further During The Insert. </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. Whenever Data Is Provided From Applications Or Products Without API's For Puling Data, On A .csv Files. In That Scenario The Data Will Be Provided On Regular Basis And Have To Be Inserted Automatically. In Such Scenarios Is Inappropriate DataBase File And Tables Creation. Therefore It Is Better The CmdLet To Throw Terminating Error And Stop Processing Instead To Create A Mess. </para> <para type="description"> Whenever Initial 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 Here Allows Greater Visibility. At The End Initial Data INSERT Is Performed Only Once, For One Time Actions Using Graphical Interface Is Always Better. </para> <para type="description"> The CmdLet Converts Each Of The Provided InputObjects To SQL Parameters Using The SQL Query And Its Variables Generated From The Table Columns. From Here Is Coming A Requirement That The InputObject Must Have PropertyNames Matching The Table Column Names. In Case Some Of The Columns In The Table Is Not Present In The InputObject Properties The CmdLet Will Insert NULL In Those Columns, Which Might Lead To Constraint Errors Whenever The Column Is Not Nullable. Additionally The Object Properties Which Are Not Present As Table Columns Are Disregarded. </para> <para type="description"> </para> <para type="description"> </para> <para type="description"> </para> <para type="description"> To Simplify The Dates Handling The Module Offers Predefined Formatting Strings To Convert DateTime Object To Understandable For SQLite Format. Although The CmdLet Will Handle SQL Parameters Without Being Converted To Strings, Before To Be Specified To CmdLet. </para> <para type="description"> Due To The Fact That SQLite Engine Converts Internally The Dates To UTC, Leaving The DateTime Objects To Be Automatically Handled Might Lead To Some Weird Results. If You Leave In Country With Daylight Saving Please Make Sure The DateTime Objects Are Converted Properly To UTC And Afterward Converted To String Which Specify To SQLite That The String Representation Of The Date Is In UTC. </para> <para type="description"> Whenever A DateTime Is Specified Within SQL Parameter HashTable Value, The CmdLet Will Convert It To SQLite Understandable String Transparently. During The Process The DateTime Object Is Handled As Follows: </para> <para type="description"> - If The Provided DateTime Object Have Kind UTC, The Object Is Converted To A String Recognizable By SQLite As UTC Time. </para> <para type="description"> - If The Provided DateTime Object Have Kind Local, The Object Is Converted To UTC Time Zone Using The .NET Conversion Method Based On The Regional Settings Of The Computer Where The CmdLet Is Run. Then Convert The UTC DateTime Object To A String Recognizable By SQLite As UTC Time. </para> <para type="description"> - If The Provided DateTime Object Have Kind Unspecified, The Object Is Converted To A String Recognizable By SQLite As Local Time Zone Leaving The DataBase To Handle The Conversion To UTC Time Zone By Itself. </para> <para type="description"> In Fact When SQL Select Query Is Used SQLite Provides The Dates In Local Time Zone And Generated DateTime Objects Have Kind Unspecified. This Does Allow The Output From One SQL Query To Be Used As Input To Another SQL Query. </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 (svesavov@hotmail.com)</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 $arrInput -SkipPrimaryKey; </code> <para> </para> <para> Convert The Specified InputObjects Collection To SQL Parameters And Insert The Data Into MyTable. </para> <para> During The Insert The Primary Key Column Will Be Not Used Because It Is AUTOINCREMENT Integer. </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> Convert The Pipelined InputObjects Collection To SQL Parameters And Insert The Data Into MyTable. </para> <para> In Case Of Entry Conflicts Between Existing And New Ones The Old Entry Will Be Replaced With The New One. </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.Password"> <summary> <para type="description">Specifies A [System.Security.SecureString] Or [System.String] Password To Use In The SQLite Connection.</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 Objects.</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="P:SnsSqlitePsModule.InvokeSnsSqliteObjectInsert.SkipPrimaryKey"> <summary> <para type="description">Specifies To Not Insert Value Into Primary Key Column.</para> <para type="description">Use It Whenever The Primary Key Value Is AutoGenerated.</para> </summary> </member> <member name="T:SnsSqlitePsModule.InvokeSnsSqliteQuery"> <summary> <para type="synopsis"> This Cmdlet Connect 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"> This Cmdlet Connect 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 Following The Links In The Link Section Below. </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"> Like The Original CmdLet Most Of The Input Is Validated At The Beginning Within The Parameter Definitions. For That Purpose Some 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 Instead Of SQLiteConnection Object Is Provided, The CmdLet Verifies The DataBase File Existence And If There Is A Need Creates The DataBase File. Automatic DataBase File Creation Does Not Work In C# For Some Reason, When A Query To Inexistent DataBase Is Sent. In Case New DataBase File Is Created, The User Is Notified With A Warning Message. </para> <para type="description"> Because The Connection Is Established In The Begin Method It Is Done Once And All The Specified Queries Are Sent At Once In The Process Method Which Gain Huge Performance Boost. </para> <para type="description"> To Boost The Performance Even Further, The CmdLet Will Execute All The Specified SQL Queries Or Single Query With Multiple Parameters Using SQL Transaction. But Only If: </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 Does Not Start With "VACUUM" Or "PRAGMA". SQLite Will Not Allow Those Queries To Be Executed Within Transaction. The CmdLet Will Verify Only The First SQL Query And Will Not Use Transaction In Case Of "PRAGMA" Or "VACUUM" Preventing Errors. In Case The CmdLet Is Cheated And Such Queries Are Sent As Consequent Queries SQLite Will Revert Errors And The Started Transaction Will Be Reverted. Which Means That The Successful Queries In The Beginning Will Be Reverted As Well. </para> <para type="description"> In Case Password Is Specified And The DataBase Doesn't Exists, The Newly Created DataBase Will Be Password Protected With The Specified Password. </para> <para type="description"> Password Can Be Specified Either As [System.String] Or As [System.Security.SecureString]. Any Other DataType Will Revert Validation Error. </para> <para type="description"> Existing DataBase File Can Be Opened As ReadOnly As Well. If The Specified DataBase Doesn't Exist And Is Created, The Specified ReadOnly Parameter Will Be Disregarded And The DataBase Will Be 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 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 Some 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"> - Single SQL Query Without Any SQL Parameters HashTable. Provided Directly To The Parameters Or As Object Property Of An Object Coming From The Pipeline. </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 Via Object Properties Of Objects Collection Coming From The Pipeline. Single Object Coming From The Pipeline Cannot Have Multiple SQL Queries. </para> <para type="description"> The New Pipeline Approach Makes No Sense "Invoke-SqliteBulkCopy" CmdLet From The Original PowerShell Module To Be Rewritten Using C# At All. Because This CmdLet Can Be Used For Bulk Uploads Without Performance Degradation. </para> <para type="description"> </para> <para type="description"> </para> <para type="description"> </para> <para type="description"> To Simplify The Dates Handling The Module Offers Predefined Formatting Strings To Convert DateTime Object To Understandable For SQLite Format. Although The CmdLet Will Handle SQL Parameters Without Being Converted To Strings, Before To Be Specified To CmdLet. </para> <para type="description"> Due To The Fact That SQLite Engine Converts Internally The Dates To UTC, Leaving The DateTime Objects To Be Automatically Handled Might Lead To Some Weird Results. If You Leave In Country With Daylight Saving Please Make Sure The DateTime Objects Are Converted Properly To UTC And Afterward Converted To String Which Specify To SQLite That The String Representation Of The Date Is In UTC. </para> <para type="description"> Whenever A DateTime Is Specified Within SQL Parameter HashTable Value, The CmdLet Will Convert It To SQLite Understandable String Transparently. During The Process The DateTime Object Is Handled As Follows: </para> <para type="description"> - If The Provided DateTime Object Have Kind UTC, The Object Is Converted To A String Recognizable By SQLite As UTC Time. </para> <para type="description"> - If The Provided DateTime Object Have Kind Local, The Object Is Converted To UTC Time Zone Using The .NET Conversion Method Based On The Regional Settings Of The Computer Where The CmdLet Is Run. Then Convert The UTC DateTime Object To A String Recognizable By SQLite As UTC Time. </para> <para type="description"> - If The Provided DateTime Object Have Kind Unspecified, The Object Is Converted To A String Recognizable By SQLite As Local Time Zone Leaving The DataBase To Handle The Conversion To UTC Time Zone By Itself. </para> <para type="description"> In Fact When SQL Select Query Is Used SQLite Provides The Dates In Local Time Zone And Generated DateTime Objects Have Kind Unspecified. This Does Allow The Output From One SQL Query To Be Used As Input To Another SQL Query. </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 (svesavov@hotmail.com)</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> Create A Table "Events" And The DataBase If It Does Not Already 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.ToString([SnsSqlitePsModule.TimeFormat]::Local); }; </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> 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> 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 Generates Warning.</para> <para type="description">Accepts Either File Name Or Full Absolute UNC Paths.</para> </summary> </member> <member name="P:SnsSqlitePsModule.InvokeSnsSqliteQuery.Password"> <summary> <para type="description">Specifies A [System.Security.SecureString] Or [System.String] Password To Use In The SQLite Connection.</para> <para type="description">In Case The DataBase Does Not Exists, The CmdLet Creates It With Specified Password.</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">CmdLet Offers Limited Support For Conversions To SQLite Friendly Formats.</para> <para type="description">If You Pass A .NET DateTime, CmdLet Converts It To A String, That SQLite Recognizes As DateTime.</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"> This Cmdlet Creates And Reverts An SQLiteConnection Object. </para> <para type="description"> This Cmdlet Creates And Reverts An SQLiteConnection Object. </para> <para type="description"> If The Specified DataBase Doesn't Exist, The CmdLet Throw A Warning And Creates The DataBase. In Case Was Requested Read Only Mode And The DataBase Is Created The Connection To It Wont Be In ReadOnly 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 Modify 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, However Using Open Parameter It Can Create The SQLiteConnection Object Without Opening Of Session. </para> <para type="description"> Normally "Invoke-SnsSqliteQuery" Creates And Opens Connections To The Required DataBases, Using The Same Logic As This CmdLet. Therefore From PowerShell Point Of View This CmdLet Is Not Required. However The "Invoke-SnsSqliteQuery" Cannot Revert The SQLiteConnection Object, Which Is Needed Whenever Performing DataBase Management And Maintenance Tasks. Here This CmdLet Comes Required. Within The Examples Section Of This Help Document Are Shown Some Of Those Management And Maintenance Tasks. </para> <list type="alertSet"> <item> <term> </term> <description> <para>AUTHOR: Svetoslav Nedyalkov Savov (svesavov@hotmail.com)</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 "temp.sqlite" -Open:$false; </code> <para> </para> <para> Creates Connection To A DataBase Located In The Working Folder Without Password And Without Opening Of The Session. </para> <para> If The DataBase File Doesn't Exist In The Current Working Folder, Creates The DataBase. Then Creates Connection To The DataBase Without Password And Without Opening Of The Session. </para> <para> </para> <para> </para> <para> </para> <code> $objConn.SetPassword("Password"); </code> <para> </para> <para> Set A Password "Password" To The DataBase Connection Object. </para> <para> NOTE: To Use SetPassword Method The Connection Must Be NOT Opened. </para> <para> </para> <para> </para> <para> </para> <code> $objConn.Open(); </code> <code> $objConn.Close(); </code> <code> $objConn.Dispose(); </code> <para> </para> <para> Commit The Changes To The DataBase File And Opens The Connection. </para> <para> The DataBase Remains Without Password Protection Until The Session Is Closed And Connection Object Disposed. </para> <para> </para> <para> </para> <para> </para> </example> <example> <code> [System.Data.SQLite.SQLiteConnection]$objConn = New-SnsSqliteConnection -DataBase "temp.sqlite" -Password "Pass"; </code> <para> </para> <para> Creates And Opens A Connection To A DataBase Located In The Working Folder With Password "Pass". </para> <para> If The DataBase File Doesn't Exist In The Current Working Folder, Creates A Password Protected DataBase With Password "Pass". Then Creates And Opens A Connection To The DataBase Using The Password. </para> <para> </para> <para> </para> <para> </para> <code> $objConn.ChangePassword("Password"); </code> <code> $objConn.Close(); </code> <code> $objConn.Dispose(); </code> <para> </para> <para> Change The DataBase Password To "Password", Closes The Connection And Dispose The Object. </para> <para> NOTE: To Use ChangePassword Method The Connection Must Be Opened. </para> <para> </para> <para> </para> <para> </para> </example> <example> <code> [System.Data.SQLite.SQLiteConnection]$objConn = New-SnsSqliteConnection -DataBase "temp.sqlite" -Password "Password"; </code> <para> </para> <para> Creates And Opens A Connection To A DataBase Located In The Working Folder With Password "Password". </para> <para> If The DataBase File Doesn't Exist In The Current Working Folder, Creates A Password Protected DataBase With Password "Password". Then Creates And Opens A Connection To The DataBase Using The Password. </para> <para> </para> <para> </para> <para> </para> <code> $objConn.ChangePassword($null); </code> <code> $objConn.Close(); </code> <code> $objConn.Dispose(); </code> <para> </para> <para> Removes The Password Protection, Closes The Connection And Dispose The Object. </para> <para> </para> <para> </para> <para> </para> </example> <example> <code> $objProdConn, $objBackupConn = New-SnsSqliteConnection -DataBase "temp.sqlite", "Backup.sqlite" -Passwrod "Pass" -ReadOnly; </code> <para> </para> <para> Creates And Opens A Connection To "temp.sqlite" DataBase Located In The Working Folder With Password In ReadOnly Mode. For The Purpose Of The Example It Needs To Be Existing DataBase File With Some 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, Password Protected, And Because It Is Now DataBase The Generated 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> Backup 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 Along With The Password Protection. </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.Password"> <summary> <para type="description">Specifies A [System.Security.SecureString] Or [System.String] Password To Use In The SQLite Connection.</para> <para type="description">In Case The DataBase Does Not Exists, The CmdLet Creates It With Specified Password.</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> |