Git Product home page Git Product logo

Comments (13)

jgallagher avatar jgallagher commented on May 24, 2024

It's not currently supported, but @gwenn opened a PR (#59) which adds support for it. I've been pretty swamped at work, but I'll try to get to that PR (and the other open ones) soon.

from rusqlite.

dashed avatar dashed commented on May 24, 2024

@jgallagher any movement on this?

from rusqlite.

gwenn avatar gwenn commented on May 24, 2024

The API provided by my PR may be to restrictive.
It's a simple transcription of the TCL API:
https://www.sqlite.org/tclsqlite.html#backup

from rusqlite.

dashed avatar dashed commented on May 24, 2024

@gwenn why is it considered restrictive?

from rusqlite.

gwenn avatar gwenn commented on May 24, 2024
  • Destination database name,
  • Number of pages copied,
  • Error (SQLITE_BUSY, SQLITE_LOCKED) handling while stepping,

are hard-coded.

from rusqlite.

jgallagher avatar jgallagher commented on May 24, 2024

@gwenn @dashed I took a shot at implementing a more robust and Rust-y interface for online backup. Could you guys please take a look at #93 and see what you think? If you have actual programs that are using this or want to use it and you could give it a shot, that would be even better.

from rusqlite.

gwenn avatar gwenn commented on May 24, 2024

Maybe I am biased.
But I think that the main use case is "Backup the current ('main') database to a file".
So it seems wise to have a simple function that makes this main use case easy to do:

impl SqliteConnection {
    pub fn backup<P: AsRef<Path>>(&self, name: BackupName, dst_path: &P) -> SqliteResult<()> {
        let dst = try!(SqliteConnection::open(dst_path));
        let backup = try!(Backup::new_with_names(&src, name, &mut dst, BackupName::Main));
        backup.run_to_completion(100, Duration::from_millis(250), None)
    }
    // And may be restore...
}

from rusqlite.

jgallagher avatar jgallagher commented on May 24, 2024

If we did add it, we'd have to make a bunch of decisions that seem a little problematic:

  • pagecount / sleep time (100/100 is used in the TCL and JDBC interfaces; the SQLite docs use 5/250 in their "how to do a backup" example)
  • Should we fail after too many BUSYs? (TCL/JDBC include this for restore but not backup)
  • Should we include a hook for a progress function? (TCL doesn't have this but JDBC does)

Given how short implementing these options would be, I lean toward letting clients decide how they want to do the backups. I could be convinced otherwise though if you feel strongly about it.

from rusqlite.

gwenn avatar gwenn commented on May 24, 2024

Another unrelated point:
At least, the following functions also take a database name ("main", "temp", ...) as argument:

So BackupName may be too specific.

from rusqlite.

jgallagher avatar jgallagher commented on May 24, 2024

Thanks, renamed it to DatabaseName in 89b5875.

I'm still going back and forth on backup and restore. I'm leaning toward going ahead and putting them in with 100/100 and including an Optional progress function (like JDBC's) - I think you're right that most uses will want something simple, and they can always use the full backup mod if they want full control. So the signatures would be

impl SqliteConnection {
    pub fn backup<P: AsRef<Path>>(&self, name: DatabaseName, dst_path: &P, progress: Option<fn(backup::Progress)>) -> SqliteResult<()> { ... }
    pub fn restore<P: AsRef<Path>>(&mut self, name: DatabaseName, src_path: &P, progress: Option<fn(backup::Progress)>) -> SqliteResult<()> { ... }
}

What do you think?

from rusqlite.

gwenn avatar gwenn commented on May 24, 2024

LGTM

from rusqlite.

jgallagher avatar jgallagher commented on May 24, 2024

Implemented as of #93.

from rusqlite.

dashed avatar dashed commented on May 24, 2024

Sorry haven't responded sooner. But the new API looks much cleaner to use! 👍

from rusqlite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.