Comments (13)
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.
@jgallagher any movement on this?
from rusqlite.
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.
@gwenn why is it considered restrictive?
from rusqlite.
- Destination database name,
- Number of pages copied,
- Error (SQLITE_BUSY, SQLITE_LOCKED) handling while stepping,
are hard-coded.
from rusqlite.
@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.
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.
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 notbackup
) - 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.
Another unrelated point:
At least, the following functions also take a database name ("main", "temp", ...) as argument:
- http://sqlite.org/c3ref/blob_open.html
- http://sqlite.org/c3ref/db_readonly.html
- http://sqlite.org/c3ref/table_column_metadata.html
- http://sqlite.org/c3ref/wal_checkpoint_v2.html
So BackupName
may be too specific.
from rusqlite.
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 Option
al 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.
LGTM
from rusqlite.
Implemented as of #93.
from rusqlite.
Sorry haven't responded sooner. But the new API looks much cleaner to use! 👍
from rusqlite.
Related Issues (20)
- release the latest version HOT 4
- FromSql vs TryFrom / ToSql vs TryInto HOT 1
- `sqlite3_compileoption_used` and Rust `const fn`
- called `Result::unwrap()` on an `Err` value: SqliteFailure(Error { code: Unknown, extended_code: 1 }, Some("json_object() requires an even number of arguments")) HOT 2
- Apps using `winsqlite3` feature no longer builds HOT 5
- Question: Is there any way to use SQLite 3.45 with rusqlite 0.30.0? HOT 2
- Trait for abstracting over `Connection`/`Transaction`? HOT 3
- SqlInputError { error: Error { code: Unknown, extended_code: 1 }, msg: "unrecognized token: \"{\"" HOT 1
- Release 0.31.0 with SQLite 3.45? HOT 2
- Type issue on select with digits only in a "string" colums. HOT 2
- wasm32-wasi target fails on Apple M3
- How to get "returning *" from insert HOT 2
- Stale Connection Handler on Multi-Threaded Situation HOT 1
- sqlite3_snapshot iteration HOT 2
- Creating `Value::Blob` without necessarily allocating heap HOT 5
- Using rusqlite::vtab::VTabConnection::handle() HOT 4
- Add bindings for `sqlite3_trace_v2` API HOT 4
- iOS Linker Warning: SQLite was build for newer version than being linked HOT 2
- the first query is failure due to below error HOT 1
- Segmentation fault when writing encrypted database with vendored SQLCipher and OpenSSL on OpenBSD
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rusqlite.