mirror of
https://github.com/TeamPiped/sponsorblock-mirror.git
synced 2024-12-13 22:00:35 +05:30
Fix transaction for import.
This commit is contained in:
parent
f97043f6a5
commit
8f4ab70581
@ -72,7 +72,7 @@ fn rocket() -> Rocket<Build> {
|
|||||||
println!("Importing database...");
|
println!("Importing database...");
|
||||||
// Execute a query of some kind
|
// Execute a query of some kind
|
||||||
db.run(move |c| {
|
db.run(move |c| {
|
||||||
let result = c.batch_execute("BEGIN TRANSACTION; DROP TABLE IF EXISTS \"sponsorTimesTemp\"; CREATE UNLOGGED TABLE \"sponsorTimesTemp\"(LIKE \"sponsorTimes\" INCLUDING defaults INCLUDING constraints INCLUDING indexes); COPY \"sponsorTimesTemp\" FROM '/mirror/sponsorTimes.csv' DELIMITER ',' CSV HEADER; DROP TABLE \"sponsorTimes\"; ALTER TABLE \"sponsorTimesTemp\" RENAME TO \"sponsorTimes\"; COMMIT; VACUUM \"sponsorTimes\";");
|
let result = c.batch_execute("BEGIN; DROP TABLE IF EXISTS \"sponsorTimesTemp\"; CREATE UNLOGGED TABLE \"sponsorTimesTemp\"(LIKE \"sponsorTimes\" INCLUDING defaults INCLUDING constraints INCLUDING indexes); COPY \"sponsorTimesTemp\" FROM '/mirror/sponsorTimes.csv' DELIMITER ',' CSV HEADER; DROP TABLE \"sponsorTimes\"; ALTER TABLE \"sponsorTimesTemp\" RENAME TO \"sponsorTimes\"; COMMIT; VACUUM \"sponsorTimes\";");
|
||||||
if result.is_err() {
|
if result.is_err() {
|
||||||
eprintln!("Failed to import database: {}", result.err().unwrap());
|
eprintln!("Failed to import database: {}", result.err().unwrap());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user