function sqlite3_backup_init(db_dst:pointer; dbname_dst: Pchar; db_src:pointer; dbname_src: Pchar):pointer; cdecl;
function sqlite3_backup_step(db_dst:pointer; count:integer):integer; cdecl;
function sqlite3_backup_finish(db_dst:pointer):integer; cdecl;
function sqlite3_backup_step; external SQLITEDLL;
function sqlite3_backup_init; external SQLITEDLL;
function sqlite3_backup_finish; external SQLITEDLL;
Код компонента:
unit hiSQLite_Backup;
interface
uses Windows,Kol,Share,Debug,SqLite3Api;
type
THISQLite_Backup = class(TDebug)
private
public
_prop_FileName1:string;
_data_FileName1:THI_Event;
_prop_FileName2:string;
_data_FileName2:THI_Event;
_data_dbHandle1:THI_Event;
_data_dbHandle2:THI_Event;
_event_onBackup:THI_Event;
procedure _work_doBackup(var _Data:TData; Index:word);
end;
implementation
uses hiCharset;
procedure THISQLite_Backup._work_doBackup;
var
dt1,dt2:TData;
id1,id2,backup:pointer;
begin
dt1 := ReadData(_Data,_data_dbHandle1);
id1 := ToObject(dt1);
dt2 := ReadData(_Data,_data_dbHandle2);
id2 := ToObject(dt2);
backup := sqlite3_backup_init(id2,PChar(CodePage1ToCodePage2(ReadString(_Data,_data_FileName2, _prop_FileName2), CP_ACP, CP_UTF8)),id1,PChar(CodePage1ToCodePage2(ReadString(_Data,_data_FileName2, _prop_FileName2), CP_ACP, CP_UTF8)));
if backup <> nil then
sqlite3_backup_step(backup,-1);
sqlite3_backup_finish(backup);
_hi_CreateEvent_(_Data, @_event_onBackup);
end;
end.
interface
uses Windows,Kol,Share,Debug,SqLite3Api;
type
THISQLite_Backup = class(TDebug)
private
public
_prop_FileName1:string;
_data_FileName1:THI_Event;
_prop_FileName2:string;
_data_FileName2:THI_Event;
_data_dbHandle1:THI_Event;
_data_dbHandle2:THI_Event;
_event_onBackup:THI_Event;
procedure _work_doBackup(var _Data:TData; Index:word);
end;
implementation
uses hiCharset;
procedure THISQLite_Backup._work_doBackup;
var
dt1,dt2:TData;
id1,id2,backup:pointer;
begin
dt1 := ReadData(_Data,_data_dbHandle1);
id1 := ToObject(dt1);
dt2 := ReadData(_Data,_data_dbHandle2);
id2 := ToObject(dt2);
backup := sqlite3_backup_init(id2,PChar(CodePage1ToCodePage2(ReadString(_Data,_data_FileName2, _prop_FileName2), CP_ACP, CP_UTF8)),id1,PChar(CodePage1ToCodePage2(ReadString(_Data,_data_FileName2, _prop_FileName2), CP_ACP, CP_UTF8)));
if backup <> nil then
sqlite3_backup_step(backup,-1);
sqlite3_backup_finish(backup);
_hi_CreateEvent_(_Data, @_event_onBackup);
end;
end.
Редактировалось 5 раз(а), последний 2017-02-07 08:01:39