postgresql – Can a transaction avoid inserting duplicate values in my database?

I have the following table named values:

id serial
user_id integer
store_id integer
identifier VARCHAR(255)
created timestamp without time zone DEFAULT NOW()

But my application has inserted following values:

id user_id store_id identifier created
1 1 1 123cdwe 2021-11-11 13:00:00
1 1 1 Ggrseza 2021-11-11 13:00:00

And that values seem wrong. What I suspect is a replication lag between master and slave alongside with an application termination right just after writing. The application is a web one and I suspect that happens whilst user ferfeshed whilst saving.

Would a transaction could solve the problem or this problem should be tackled at application level?

data recovery – Missing photos after inserting external sd card into Samsung galaxy Tab s6 lite

I want to appologize in advance if this is the wrong forum.

Whats the problem?

I am photographing on my fuji xt4 and wanted to transfer all photos to my Samsung galaxy S6 Lite (using a basic card reader). The storage is correctly recognized and mounted. The first few times were no problem. However now all photos up from a certain point are not displayed/lost. Once inserted into the tablet the new photos and Videos are permanently gone (the camera doesnt displays them either).

  • Sony tough sd card 64gb (exFat)
  • Fujifilm xt4
  • Samsung galaxy tab s6lite (Android 11, not rooted)

What i tried

  • rebooting the tablet
  • reinserting the sd card
  • different card reader
  • accessing the photos by connecting to the camera via ptp is no problem
  • using more powerful file browser did not reveal anything new

I have currently no access to a normal computer and therefore cant properly investigate the problem further. I tried nearly all recovery android Apps but none scanned extertal USB storage. My last idea was to mask the card reader as internal sd card but Samsung seems to Block adoptable storage and any further advances in included formating the sd card.
My best guess is that my tablet is resetting the block-bitmap from the sd card to the state of the last time it was mounted.
Has anyone an idea on what is happening and what the best approach in recovering the lost data may be?

plugins – wp_insert_post not inserting post from XML

I’m using below to read XML file and import its content as a page in wordpress, but it’s not working:

add_action('import_demo', 'importIt');
function importIt(){
    // The code until now
    $path = get_template_directory() . '/demo/pages.xml';
    $xml = simplexml_load_file($path);
    foreach ($xml->channel->item as $item) {
        $postCreated = array(
            'post_title'    => $item->title,
            'post_content'  => $item->content,
            // 'post_excerpt'  => $item->excerpt,
            'post_status'   => 'publish',
            'post_type'     => 'page', // Or "page" or some custom post type
        );

        $postInsertId = wp_insert_post( $postCreated );

        add_action('add_attachment','featuredImageTrick');
        media_sideload_image($item->image, $postInsertId, $item->title);
        remove_action('add_attachment','featuredImageTrick');

        function featuredImageTrick($att_id){
            $p = get_post($att_id);

            update_post_meta($p->post_parent,'_thumbnail_id',$att_id);
        }
    }
}

Python Selenium Telegram Media Inserting

Python Selenium Telegram Media Inserting – Software Engineering Stack Exchange

Inserting a new Sheet from a Template into an existing spreadsheet in Google Sheets

I know how to insert a new blank sheet in Google Sheets to an existing spreadsheet, but how do you insert a new Sheet from a Template to an existing spreadsheet document?

For example, if I have a spreadsheet that was created from the “To Do” template, I’d like to add a new sheet to that document using the “To Do” template again, not just a blank sheet.

google sheets – Need help referencing data from another tab and inserting the result in a single cell

Enter this formula in sheet “Prepack Dashboard”, cell E2.

=ArrayFormula(IF(isblank($A2:$A),"",VLOOKUP(A2:A&B2:B,{'Inventory Minimums'!$A$2:$A&'Inventory Minimums'!$B$2:$B, 'Inventory Minimums'!C2:C},2,0)))

Breakdown
VLOOKUP looking up an array (the part in curly braces)

  • VLOOKUP(A2:A&B2:B,{'Inventory Minimums'!$A$2:$A&'Inventory Minimums'!$B$2:$B, 'Inventory Minimums'!C2:C},2,0)
  • this takes the combined value of the “Strain” and “Inventory Type” from columns A&B of “Prepack Dashboard”, and looks that up in the combined columns A & B of “Inventory Minimums”
  • when it finds the lookup value, it returns the value from Column C (which is the minimum quantity).

ARRAYFORMULA

  • This allows the formula to be automatically copied down for as many rows as there is data. Without this, VLOOKUP would have had to be copied manually. Even if ARRAYFORMULA was applied to the VLOOKUP, it would not automatically copy it down the column.

IF and ISBLANK

  • This is the “trick” that enables ARAYFORMULA to copy the VLOOKUP formula down the column.
  • This passes an array to ARRAYFORMULA which it can useuses to copy down the column.

postgresql – Inserting into multiple tables with a foreign compound key

I have these two table that I would like to insert alot of data into.

CREATE TABLE IF NOT EXISTS N
(
    id                      INT GENERATED ALWAYS AS IDENTITY,
    name varchar(50)
);

CREATE TABLE IF NOT EXISTS ConnectionProps
(
    connectionProp  INT,
    FK_n INTEGER,
    PRIMARY KEY (connectionProp,FK_n),
    CONSTRAINT FK_n
        FOREIGN KEY(id)
            REFERENCES N(id)
                ON DELETE CASCADE
);

I need to insert into both tables at the same time as the primary key of the connectionprops table is a compound key of the foreignkey of N and connectionProps. How do I do this?

sql server – Inserting across different Partitions within a Partitioned Table

Physically each partition is stored a separate data structure, and only the Query Optimizer knows that they make up one logical table.

So you shouldn’t expect a significant difference in inserting into one partition or another.

If your table is a clustered index it can be more expensive to insert into the “middle” than the “end”, but that’s mostly unrelated to whether the clustered index is partitioned.

sql server – after insert trigger not firing after inserting with bcp

content of csv file

TEST_1|sl2sysxbar301.dv.local|{'message_type': 2, 'super_evt_non_error': {'a0': 0, 'a1': 0, 'a2': 0, 'a3': 0, 'event': 5528, 'event_string': 'ENERGY_CTRL_RIGHT_PROX_DOWN', 'history_buffer_id': 3, 'history_buffer_string': 'HISTORY_BUFFER_UI_EVT', 'mid': 10, 'mid_string': 'CONSOLE1'}}|2021-06-26 05:03:20|
TEST_11|sl2sysxbar301.dv.local|{'message_type': 2, 'super_evt_non_error': {'a0': 393280, 'a1': 1, 'a2': 0, 'a3': 0, 'event': 8316, 'event_string': 'BP_FOLLOW_CHECK', 'history_buffer_id': 0, 'history_buffer_string': 'HISTORY_BUFFER_BP', 'mid': 6, 'mid_string': 'MTMR'}}|2021-06-26 05:03:20|
TEST_2|sl2sysxbar301.dv.local|{'message_type': 4, 'mmdsp_log': {'bp_start': {'bp_arg': 0.0, 'bp_code': 4097, 'bp_sn': 393300, 'mid': 6}, 'legacy_log_idx': 0}}|2021-06-26 05:03:20|
TEST_4|sl2sysxbar301.dv.local|{'message_type': 2, 'super_evt_non_error': {'a0': 267, 'a1': 0, 'a2': 0, 'a3': 0, 'event': 100001, 'event_string': 'INTER_MANIP', 'history_buffer_id': 3, 'history_buffer_string': 'HISTORY_BUFFER_UI_EVT', 'mid': 1, 'mid_string': 'AIM2'}}|2021-06-26 05:03:20|

here is bcp running via python

            p = subprocess.Popen(
                f'/opt/mssql-tools/bin/bcp {app.config.db_table_name} in {f.get("filename")}  -S {app.config.db_host},{app.config.db_port} -U {app.config.db_username} -P {app.config.db_password} -t  "|"  -c',
                shell=True,
                stdout=subprocess.PIPE,
                stderr=subprocess.STDOUT
            )

I have this table and trigger

CREATE TABLE (EVT_STREAM).(Event)(
    (SystemName) (varchar)(25) NOT NULL,
    (Router) (varchar)(128) NULL,
  (Event) (nvarchar)(max) NULL,
  (ReceivedAt) (datetime) NOT NULL,
  (InsertedAt) (datetime) NULL
)ON (PRIMARY)
GO

CREATE TRIGGER (EVT_STREAM).(trg_EVT_STREAM)
   ON (EVT_STREAM).(Event)
   FOR INSERT
AS
BEGIN
SET NOCOUNT ON;
insert into (EVT_STREAM).(Event)(
  (InsertedAt)
)
  VALUES(
    GETUTCDATE()
    )
END
GO

ALTER TABLE (EVT_STREAM).(Event) ENABLE TRIGGER (trg_EVT_STREAM)
GO

basically I would like to update (InsertedAt) at the time when BCP runs and inserts CSV records in (EVT_STREAM).(Event) table.

DreamProxies - Cheapest USA Elite Private Proxies 100 Cheapest USA Private Proxies Buy 200 Cheap USA Private Proxies 400 Best Private Proxies Cheap 1000 USA Private Proxies 2000 USA Private Proxies 5000 Cheap USA Private Proxies ExtraProxies.com - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies ProxiesLive.com Proxies-free.com New Proxy Lists Every Day Proxies123.com Proxyti.com Buy Quality Private Proxies