Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: [OT] SQL "on duplicate key" custom action

by perlfan (Vicar)
on Oct 13, 2021 at 01:02 UTC ( #11137458=note: print w/replies, xml ) Need Help??


in reply to [OT] SQL "on duplicate key" custom action

It depends on what DB, but it's basically the following to "ignore" it,
INSERT INTO records (PriKey, Foo, Bar) VALUES (1, 'Hello', World') ON DUPLICATE KEY UPDATE Foo=Foo;
Some track the attempts, though; using the equivalent to a column named Attempts. But I am not sure how useful that is in practice tbh:
INSERT INTO records (PriKey, Foo, Bar) VALUES (1, 'Hello', World') ON DUPLICATE KEY UPDATE Attempts=Attempts+1;
> Since I can choose the DB, what is your opinion on MySQL vs. Postgres?

It really depends; frankly I don't do anything these days that even requires a DB server so usually I go with DBD::SQLite. That has it's own things to deal with (forks, etc) but it makes my life a lot easier not to have to maintain DB servers and all that stuff. YMMV based on the application though.

Most relevant from the YMMV link,

SQLite does not compete with client/server databases. SQLite competes with fopen().

Replies are listed 'Best First'.
Re^2: [OT] SQL "on duplicate key" custom action
by haukex (Bishop) on Oct 13, 2021 at 09:47 UTC
    It depends on what DB, but it's basically the following to "ignore" it, INSERT INTO records (PriKey, Foo, Bar) VALUES (1, 'Hello', World') ON DUPLICATE KEY UPDATE Foo=Foo;

    How does that address my question?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11137458]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2021-12-09 10:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (36 votes). Check out past polls.

    Notices?