<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://communities.bentley.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Performance monitor - Merge SQLite databases if running from separate regions - Just Sharing</title><link>https://communities.bentley.com/products/projectwise/f/projectwise-powershell-extensions-forum/247062/performance-monitor---merge-sqlite-databases-if-running-from-separate-regions---just-sharing</link><description>Maybe someone has a PowerShell script to do the same thing or a neater way? (Merging multiple sqlite databases to one - Machines were from different regions with no access to a central db) For this I required sqlite3.exe from the sqlite tools bundle and</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Performance monitor - Merge SQLite databases if running from separate regions - Just Sharing</title><link>https://communities.bentley.com/thread/771346?ContentTypeID=1</link><pubDate>Wed, 28 Jun 2023 14:28:46 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:62c7d463-7401-4a2e-a008-d4b6a4d73049</guid><dc:creator>Kevin van Haaren</dc:creator><description>&lt;p&gt;I use the SimplySQL powershell module to work with SQLite from powershell but I&amp;#39;ve never tried to do any table merges from 2 different datasources with it.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/mithrandyr/SimplySql"&gt;GitHub - mithrandyr/SimplySql: PowerShell module for querying various SQL databases&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The Invoke-SQLBulkCopy might make it easier:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;
NAME
    Invoke-SqlBulkCopy
    
SYNOPSIS
    Executes a bulk copy between two connections.
    
    
SYNTAX
    Invoke-SqlBulkCopy [-SourceConnectionName &amp;lt;String&amp;gt;] [-DestinationConnectionName &amp;lt;String&amp;gt;] -SourceTable &amp;lt;String&amp;gt; 
    [-DestinationTable &amp;lt;String&amp;gt;] [-ColumnMap &amp;lt;Hashtable&amp;gt;] [-BatchSize &amp;lt;Int32&amp;gt;] [-BatchTimeout &amp;lt;Int32&amp;gt;] [-Notify] [-NotifyAction 
    &amp;lt;ScriptBlock&amp;gt;] [&amp;lt;CommonParameters&amp;gt;]
    
    Invoke-SqlBulkCopy [-SourceConnectionName &amp;lt;String&amp;gt;] [-DestinationConnectionName &amp;lt;String&amp;gt;] -SourceQuery &amp;lt;String[]&amp;gt; 
    [-SourceParameters &amp;lt;Hashtable&amp;gt;] -DestinationTable &amp;lt;String&amp;gt; [-ColumnMap &amp;lt;Hashtable&amp;gt;] [-BatchSize &amp;lt;Int32&amp;gt;] [-BatchTimeout &amp;lt;Int32&amp;gt;] 
    [-Notify] [-NotifyAction &amp;lt;ScriptBlock&amp;gt;] [&amp;lt;CommonParameters&amp;gt;]
    
    
DESCRIPTION
    Executes a bulk copy operation between two connections.  This is highly
    optimized if the destination has a managed bulkcopy implemenation, otherwise
    it is only generally optimized.  For example, SQL Server has a bulk copy
    class (SqlBulkCopy) that is easily implemented and provides an efficient
    means of inserting data into SQL Server.
    
    The default implemenation, if the provider does not provider a managed 
    bulk copy mechanism is to prepare the sql insert, and wrap multiple inserts
    into a single transaction (batching).  This provides a significant
    performance improvement over looping with Invoke-SqlUpdate.
    
    CONSIDERATIONS
    * You must specify either a SourceConnectionName or DestinationConnectionName,
        whichever one is not specified will use &amp;#39;default&amp;#39;, not specifying either
        will cause an error.     
    * If you don&amp;#226;?Tt specify DestinationTable, it will use SourceTable; however
        DestinationTable is required if you use SourceQuery.
    * If you specify ColumnMap and Source Table, then the select against the
        SourceConnection will be limited to the columns you specified in ColumnMap.
    
    Returns number of rows copied.
    

PARAMETERS
    -SourceConnectionName &amp;lt;String&amp;gt;
        User defined name for connection where data will be queried from.
        
    -DestinationConnectionName &amp;lt;String&amp;gt;
        User defined name for connection where data will be inserted to.
        
    -SourceTable &amp;lt;String&amp;gt;
        The name of the table in the source connection.
        
    -SourceQuery &amp;lt;String[]&amp;gt;
        The query to determine the source data, instead of specifying a table.
        
    -SourceParameters &amp;lt;Hashtable&amp;gt;
        Parameters needed for the source query.
        
    -DestinationTable &amp;lt;String&amp;gt;
        The name of the table to write to in the destination connection.
        If not specified, will be taken from SourceTable parameter.
        
    -ColumnMap &amp;lt;Hashtable&amp;gt;
        Key is the column name in the source connection.
        Value is the column name in the destination connection.
        
    -BatchSize &amp;lt;Int32&amp;gt;
        How many inserts are batched together at one time.
        
    -BatchTimeout &amp;lt;Int32&amp;gt;
        How long, in seconds, that each batch can take.
        Defaults to the command timeout for the source connection.
        
    -Notify [&amp;lt;SwitchParameter&amp;gt;]
        If present, as each batch completes a progress notification will be
        generated with the total number of rows inserted so far.
        
    -NotifyAction &amp;lt;ScriptBlock&amp;gt;
        If specified, then on the completion of each batch, this action will be invoked.
        The first argument will have the rows completed so far, either use $args[0]
        or specify a param block.
        
    &amp;lt;CommonParameters&amp;gt;
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer, PipelineVariable, and OutVariable. For more information, see 
        about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216). 
    
REMARKS
    To see the examples, type: &amp;quot;get-help Invoke-SqlBulkCopy -examples&amp;quot;.
    For more information, type: &amp;quot;get-help Invoke-SqlBulkCopy -detailed&amp;quot;.
    For technical information, type: &amp;quot;get-help Invoke-SqlBulkCopy -full&amp;quot;.
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>