Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: DBI/MySQL/MariaDB clone tables across DB Connections

by NERDVANA (Deacon)
on Feb 17, 2023 at 06:11 UTC ( [id://11150470]=note: print w/replies, xml ) Need Help??


in reply to DBI/MySQL/MariaDB clone tables across DB Connections

If I were doing this with DBIC, it would be as simple as making two connections, and then:
my $txn= $db2->txn_scope_guard; $db2->resultset($table)->populate([ $db1->resultset($table)->hri->all ]); $txn->commit;
assuming you can disable the foreign key checks on the temporary table. If you can't, you'd have to sort the rows so parents come before children, and then that gets more complicated if there is a auto-increment ID column.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-03-28 23:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found