Class | SQLite3::Backup |
In: |
ext/sqlite3/backup.c
|
Parent: | Object |
call-seq: SQLite3::Backup#pagecount
Returns the total number of pages in the source database file.
Note that the value is only updated after step() is called, so before calling step() returned value is invalid.
Initialize backup the backup.
dstdb:
the destination SQLite3::Database object.
dstname:
the destination's database name.
srcdb:
the source SQLite3::Database object.
srcname:
the source's database name.
The database name is "main", "temp", or the name specified in an ATTACH statement.
This feature requires SQLite 3.6.11 or later.
require 'sqlite3' sdb = SQLite3::Database.new('src.sqlite3') ddb = SQLite3::Database.new(':memory:') b = SQLite3::Backup.new(ddb, 'main', sdb, 'main') p [b.remaining, b.pagecount] # invalid value; for example [0, 0] begin p b.step(1) #=> OK or DONE p [b.remaining, b.pagecount] end while b.remaining > 0 b.finish ddb = SQLite3::Database.new(':memory:') b = SQLite3::Backup.new(ddb, 'main', sdb, 'main') b.step(-1) #=> DONE b.finish
Copy database pages up to nPage. If negative, copy all remaining source pages.
If all pages are copied, it returns SQLite3::Constants::ErrorCode::DONE. When coping is not done, it returns SQLite3::Constants::ErrorCode::OK. When some errors occur, it returns the error code.