DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: wjy13061029975
今日帖子: 1
在线用户: 2
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/7/20 2:56:23
标题:
Delphi backup SQLite in-Memory to DB in file using TFDSQLiteBackup class 浏览:2499
加入我的收藏
楼主: Delphi backup SQLite in-Memory to DB in file using TFDSQLiteBackup class
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/7/20 3:08:36
1楼: implementation

uses
  FireDAC.Phys.SQLiteWrapper;

{$R *.dfm}

const
  SQLiteDBDiskName: string = 'D:\RADRX111Tests\__temp\VCL_SQLite_create_db\Win32\Debug\HelloSQLite.db';

  SQLiteCreateTable1: string =          { }
    'create table IF NOT EXISTS MyTable1' + { }
    '(id integer PRIMARY KEY ASC, names char(30)) ';

  SQLiteCreateTable2: string =          { }
    'create table IF NOT EXISTS MyTable2' + { }
    '(id integer PRIMARY KEY ASC, others char(10)) ';

var
  MyPhysSQLiteDriverLink: TFDPhysSQLiteDriverLink;
  MyFDConnectionDisk    : TFDConnection;
  MyFDConnectionMem     : TFDConnection;

  //
  // by default im using "all default classes configurations"
  //

procedure TForm1.FDSQLiteBackup1AfterExecute(Sender: TObject);
begin
  Memo1.Lines.Add('after execute backup');
end;

procedure TForm1.FDSQLiteBackup1BeforeExecute(Sender: TObject);
begin
  Memo1.Lines.Add('before execute backup');
end;

procedure TForm1.FDSQLiteBackup1Error(ASender, AInitiator: TObject; var AException: Exception);
begin
  Memo1.Lines.Add('error backup: ' + AException.Message);
end;

procedure TForm1.FDSQLiteBackup1Progress(ASender: TFDPhysDriverService; const AMessage: string);
begin
  Memo1.Lines.Add(AMessage);
end;
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/7/20 3:08:54
2楼: procedure TForm1.FormCreate(Sender: TObject);
begin
  DeleteFile('HelloSQLite.db'); // deleting old db files for tests...
  //
  MyPhysSQLiteDriverLink          := TFDPhysSQLiteDriverLink.Create(Self);
  MyPhysSQLiteDriverLink.VendorLib := 'C:\RADStudio\bin\sqlite3.dll';
  //
  MyFDConnectionDisk := TFDConnection.Create(Self);
  MyFDConnectionMem  := TFDConnection.Create(Self);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  MyFDConnectionMem.Free;
  MyFDConnectionDisk.Free;
  MyPhysSQLiteDriverLink.Free;
end;

procedure TForm1.BtnCreatingDatabasesClick(Sender: TObject);
begin
  // mem db
  MyFDConnectionMem.LoginPrompt := false;
  MyFDConnectionMem.DriverName  := 'sQLite';
  MyFDConnectionMem.Params.Add('Database=:memory:');
  MyFDConnectionMem.Params.Add('DriverID=sQLite');
  MyFDConnectionMem.Open;
  //
  MyFDConnectionMem.ExecSQL(SQLiteCreateTable1, false);
  MyFDConnectionMem.ExecSQL(SQLiteCreateTable2, false);
  //
  MyFDConnectionMem.GetTableNames('', '', '', ListBox1.Items);
  //
  FDQuery1.Connection := MyFDConnectionMem;
  FDQuery1.Open('select * from MyTable1');
  FDQuery2.Connection := MyFDConnectionMem;
  FDQuery2.Open('select * from MyTable2');

  //
  // phisical db
  MyFDConnectionDisk.LoginPrompt := false;
  MyFDConnectionDisk.DriverName  := 'sQLite';
  MyFDConnectionDisk.Params.Add('Database=' + SQLiteDBDiskName);
  MyFDConnectionDisk.Params.Add('DriverID=sQLite');
  MyFDConnectionDisk.Open;
  //
  MyFDConnectionDisk.ExecSQL(SQLiteCreateTable1, false);
  MyFDConnectionDisk.ExecSQL(SQLiteCreateTable2, false);
  //
  MyFDConnectionDisk.GetTableNames('', '', '', ListBox2.Items);
  //
  FDQuery3.Connection := MyFDConnectionDisk;
  FDQuery3.Open('select * from MyTable1');
  FDQuery4.Connection := MyFDConnectionDisk;
  FDQuery4.Open('select * from MyTable2');
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  if MyFDConnectionMem.InTransaction then
  begin
    MyFDConnectionMem.Commit;
    //
    ShowMessage('mem Commited');
  end;
end;

procedure TForm1.BtnBackupDatabaseClick(Sender: TObject);
var
  MyFDSQLiteBackup: TFDSQLiteBackup;
begin
  if not(MyFDConnectionMem.CliObj = nil) then
  begin
    MyFDSQLiteBackup := TFDSQLiteBackup.Create(Self);
    try
      MyFDConnectionDisk.Close; // close me please!
      //
      MyFDSQLiteBackup.DriverLink := MyPhysSQLiteDriverLink;
      //
      MyFDSQLiteBackup.DatabaseObj := MyFDConnectionMem.CliObj; // in-memory
      //
      MyFDSQLiteBackup.DestDatabase := SQLiteDBDiskName;
      MyFDSQLiteBackup.DestMode     := TSQLiteDatabaseMode.smCreate; // if not "exists", create!
      //
      // MyFDSQLiteBackup.WaitForLocks := true; // wait me ... by default!
      // MyFDSQLiteBackup.BusyTimeout  := 100;  // 10.000 default!
      //
      MyFDSQLiteBackup.Backup;
      //
      MyFDConnectionDisk.Open;
      MyFDConnectionDisk.GetTableNames('', '', '', ListBox2.Items);
      //
      // ListBox2.Items.Add('time: ' + TimeToStr(now));
      //
      FDQuery3.Open('select * from MyTable1');
      FDQuery4.Open('select * from MyTable2');
    finally
      MyFDSQLiteBackup.Free;
    end;
  end;
end;

end.
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/7/20 3:09:37
3楼: screenshot
此帖子包含附件:
PNG 图像
大小:36.6K
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/7/20 3:10:18
4楼: No "incremental backup", just "inserts"!
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/7/20 3:34:29
5楼: for update like "incremental", try another approach...

1) SQLite commands, like:
INSERT OR REPLACE INTO table(column_list) VALUES(value_list);

UPDATE tablex SET fieldx=valuex WHERE <<conditional>>  by SQL default

SELECT column_1 FROM table_1 WHERE column_1 = ( SELECT column_1  FROM table_2 );

2) for "catch" only new records, try:
SELECT select_list1
  FROM table1

INTERSECT

SELECT select_list2
  FROM table2


3) for "catch" only records not contained in "right-table_list2"

SELECT select_list1
  FROM table1
EXCEPT
  SELECT select_list2
FROM table2
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/7/20 3:55:35
6楼: NOTE: 
--- your "Backup resulted" will be always a "SQLite" db, then you can use it any other db!!!
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/7/20 4:17:00
7楼: to "catch" the metadata you can:

1) use the "FDConnection.GetXXXXXX" functions to "walk" in your structure

GetCatalogNames - the catalog list;
GetSchemaNames - the schema list;
GetTableNames - the table and view list;
GetFieldNames - the table field list;
GetKeyFieldNames - the table primary key list;
GetGeneratorNames - the generator / sequence list;
GetPackageNames - the package list;
GetStoredProcNames - the stored procedure list.

so, you can use "FOR ..." looping to create your SQL script

Catalogues -> Schema -> Table -> Fields -> KeyFields -> Generators -> Pacakages -> StoredProcs -> records....

NOTE: for easy "export/import" records, you can use "TBatchMove" class to export to a CSV file, for example!

tip: export "INTERSECTed" records, import only new records >:)))

----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/7/20 5:01:53
8楼: another way to "catch" all metadata is like in Firebird (consulting the internal database tables -> system-tables )

in SQLite you:

  FDQuery5.Close;
  FDQuery5.Connection := MyFDConnectionDisk;
  // type, name, tbl_name, rootpage, sql
  FDQuery5.SQL.Text := 'select * from sqlite_master'; // where type=''table'' and name not like ''sqlite_%''';
  DBMemo1.DataField := 'type'; // blob fields
  DBMemo2.DataField := 'name';
  DBMemo3.DataField := 'tbl_name';
  DBMemo4.DataField := 'sql';
  FDQuery5.Open;
此帖子包含附件:
PNG 图像
大小:13.6K
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 sxqwhxq (步惊云) ★☆☆☆☆ -
普通会员
2022/7/20 8:42:18
9楼:  emailx45 (emailx45):谢谢巴西大师,可是我用的是lazarus,没有TFDSQLiteBackup组件,不知lazarus有没有类似的功能?
----------------------------------------------
-
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/7/20 9:36:09
10楼: @sxqwhxq you dont need use "TFDSQLiteBackup"  at all.

you can use "SQL commands" directly in your SQL as showed above!

if you need "catch" the metadata in your database, just use some like this:
select * from sqlite_master;  <-- these is the system-table in SQLite!

exists another system-tables, but in "sqlite_master" is where the "sql used in your db definition is stored"

----------
TFDSQLiteBackup dont do the backup, at all, it calls a funcion with these signature in DLL SQLite3:

Fsqlite3_backup_init(DestinationDatabase.Handle, PByte(sDestDB), SourceDatabase.Handle, PByte(sSrcDB));

in SQLite exists this function:  sqlite3_backup_init()

sqlite3_backup *sqlite3_backup_init(
  sqlite3 *pDest,          /* Destination database handle */
  const char *zDestName,          /* Destination database name */
  sqlite3 *pSource,          /* Source database handle */
  const char *zSourceName          /* Source database name */
);
int sqlite3_backup_step(sqlite3_backup *p, int nPage);
int sqlite3_backup_finish(sqlite3_backup *p);
int sqlite3_backup_remaining(sqlite3_backup *p);
int sqlite3_backup_pagecount(sqlite3_backup *p);

----------
uses
  sqlite3backup;
 
procedure BackupSQL(Conn: TSQLite3Connection; FileName: string);
var
  f: string;
  BK: TSQLite3Backup;
begin
  f := ChangeFileEXT(FileName, '') + ' [Backup ' +
    FormatDateTime('yyyy.mm.dd hh-nn-ss', Now) + '].sql';
  BK := TSQLite3Backup.Create;
  BK.Backup(Conn, f);
  BK.Free;
end
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/7/20 9:59:30
11楼: According to SQLite site this is not recommended (using CopyFile)
https://www.sqlite.org/backup.html
Quote
Historically, backups (copies) of SQLite databases have been created using the following method:
    1.Establish a shared lock on the database file using the SQLite API (i.e. the shell tool).
    2.Copy the database file using an external tool (for example the unix 'cp' utility or the DOS 'copy' command).
    3.Relinquish the shared lock on the database file obtained in step 1.

This procedure works well in many scenarios and is usually very fast. However, this technique has the following shortcomings:
    *Any database clients wishing to write to the database file while a backup is being created must wait until the shared lock is relinquished.
    *It cannot be used to copy data to or from in-memory databases.
    *If a power failure or operating system failure occurs while copying the database file the backup database may be corrupted following system recovery.

The Online Backup API was created to address these concerns. The online backup API allows the contents of one database to be copied into another database, overwriting the original contents of the target database. The copy operation may be done incrementally, in which case the source database does not need to be locked for the duration of the copy, only for the brief periods of time when it is actually being read from. This allows other database users to continue uninterrupted while a backup of an online database is made.

And According to FPC wiki http://wiki.freepascal.org/SQLite#sqlite3backup
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 sxqwhxq (步惊云) ★☆☆☆☆ -
普通会员
2022/7/20 10:26:43
12楼: 我在网上找到一份sqlite3backup.pas,它无法将内存数据库进行备份,产生的文件是空的,如果是文件数据库,它可以备份,但不会备份为sql文件。
----------------------------------------------
-
作者:
男 keymark (嬲) ▲▲▲△△ -
普通会员
2022/7/20 14:16:41
13楼: to 12楼:  
https://docwiki.embarcadero.com/RADStudio/Sydney/en/Delphi_to_C%2B%2B_types_mapping 官方delphi to c数据类型表

https://wiki.freepascal.org/Pascal_for_C_users 官方freepascal to c数据类型表

学习下咋翻译 c 到 pascal吧。不难。
结合你帖子 我回复的代码  就能搞定了。 
我没记错的话你会破解调试肯定没问题。
----------------------------------------------
[alias]  co = clone --recurse-submodules  up = submodule update --init --recursiveupd = pullinfo = statusrest = reset --hard懒鬼提速https://www.cctry.com/>http://qalculate.github.io/downloads.htmlhttps://www.cctry.com/
作者:
男 sxqwhxq (步惊云) ★☆☆☆☆ -
普通会员
2022/7/20 15:37:51
14楼: 楼上,用这种方法就算把C翻译为pascal,也只能产生sqlite格式.db文件,并不能产生ddl的sql文件,因此是SQLite3Backup(memory_db, file_db);只是备份数据到数据库文件,这样做就失去了使用内存数据库的主要作用。
使用内存数据主要作用,并非为了速度,而是为了加密,因为sqlite3的速度是非常好的,如果能下载就能对sql文件加密,sqlite3在firedac\unidac是可以加密的,但在lazarus arm里,暂时没办法加密,而自己写代码加密是非常难且不可靠的。
----------------------------------------------
-
作者:
男 lordaeron (Terry) ★☆☆☆☆ -
禁用账号
2022/7/20 16:07:23
15楼: ……
被禁用帐号,帖子内容自动屏蔽!
……

----------------------------------------------
该账号是个傻逼
作者:
男 sxqwhxq (步惊云) ★☆☆☆☆ -
普通会员
2022/7/20 16:20:53
16楼: 谢谢,没找到可用的,找到一个据说可以加密的libsqlite3.so,使用时报不能装入,要求检查编译目标平台的兼容性
----------------------------------------------
-
作者:
男 keymark (嬲) ▲▲▲△△ -
普通会员
2022/7/20 16:24:12
17楼: 那你只有去看
sqlite3.exe   
.dump的代码了
网上的 都是 sqlite3.exe    dump 出来的插入语句
没看到有人写c cpp 代码 (py有)

我猜dump 文件数据库和内存数据库差别不大吧
----------------------------------------------
[alias]  co = clone --recurse-submodules  up = submodule update --init --recursiveupd = pullinfo = statusrest = reset --hard懒鬼提速https://www.cctry.com/>http://qalculate.github.io/downloads.htmlhttps://www.cctry.com/
作者:
男 sxqwhxq (步惊云) ★☆☆☆☆ -
普通会员
2022/7/20 16:34:23
18楼: 网上找到的sqlite3backup.pas明确提出不支持内存模式。我试了,内存模式生成的文件大小是零,但物理数据库可以导出,但这个没什么用,我备份文件直接断开连接然后拷文件就可以了。
----------------------------------------------
-
作者:
男 keymark (嬲) ▲▲▲△△ -
普通会员
2022/7/20 17:28:50
19楼: int sqlite3_db_dump(
  sqlite3 *db,          /* The database connection */  //不用说了绝壁可以用内存的
  const char *zSchema,       /* Which schema to dump.  Usually "main". */
  const char *zTable,        /* Which table to dump.  NULL means everything. */
  int (*xCallback)(const char*,void*),   /* Output sent to this callback */
  void *pArg          /* Second argument of the callback */
)

dbdump.c — 这实际上不是一个可加载的扩展,而是一个实现近似等效于命令行 shell 的 “.dump” 命令的库。

https://github.com/mackyle/sqlite/blob/0ab6f6f4c9142a55959ed2097734942c1781b538/ext/misc/dbdump.c



filedb open /home/make1/test.db success
memdb open /home/make1/test.db success
filedb creat table suc
memdb creat table suc
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE testTable(ID TEXT,value);
INSERT INTO testTable(rowid,ID,value) VALUES(1,'1234',500);
INSERT INTO testTable(rowid,ID,value) VALUES(2,'1234',501);
INSERT INTO testTable(rowid,ID,value) VALUES(3,'1234',502);
INSERT INTO testTable(rowid,ID,value) VALUES(4,'1234',503);
INSERT INTO testTable(rowid,ID,value) VALUES(5,'1234',504);
INSERT INTO testTable(rowid,ID,value) VALUES(6,'1234',505);
INSERT INTO testTable(rowid,ID,value) VALUES(7,'1234',506);
INSERT INTO testTable(rowid,ID,value) VALUES(8,'1234',507);
INSERT INTO testTable(rowid,ID,value) VALUES(9,'1234',508);
INSERT INTO testTable(rowid,ID,value) VALUES(10,'1234',509);
INSERT INTO testTable(rowid,ID,value) VALUES(11,'1234',510);
INSERT INTO testTable(rowid,ID,value) VALUES(12,'1234',511);
INSERT INTO testTable(rowid,ID,value) VALUES(13,'1234',512);
INSERT INTO testTable(rowid,ID,value) VALUES(14,'1234',513);
INSERT INTO testTable(rowid,ID,value) VALUES(15,'1234',514);
INSERT INTO testTable(rowid,ID,value) VALUES(16,'1234',515);
INSERT INTO testTable(rowid,ID,value) VALUES(17,'1234',516);
INSERT INTO testTable(rowid,ID,value) VALUES(18,'1234',517);
INSERT INTO testTable(rowid,ID,value) VALUES(19,'1234',518);
INSERT INTO testTable(rowid,ID,value) VALUES(20,'1234',519);
INSERT INTO testTable(rowid,ID,value) VALUES(21,'1234',520);
INSERT INTO testTable(rowid,ID,value) VALUES(22,'1234',521);
INSERT INTO testTable(rowid,ID,value) VALUES(23,'1234',522);
INSERT INTO testTable(rowid,ID,value) VALUES(24,'1234',523);
INSERT INTO testTable(rowid,ID,value) VALUES(25,'1234',524);
INSERT INTO testTable(rowid,ID,value) VALUES(26,'1234',525);
INSERT INTO testTable(rowid,ID,value) VALUES(27,'1234',526);
INSERT INTO testTable(rowid,ID,value) VALUES(28,'1234',527);
INSERT INTO testTable(rowid,ID,value) VALUES(29,'1234',528);
INSERT INTO testTable(rowid,ID,value) VALUES(30,'1234',529);
INSERT INTO testTable(rowid,ID,value) VALUES(31,'1234',530);
INSERT INTO testTable(rowid,ID,value) VALUES(32,'1234',531);
INSERT INTO testTable(rowid,ID,value) VALUES(33,'1234',532);
INSERT INTO testTable(rowid,ID,value) VALUES(34,'1234',533);
INSERT INTO testTable(rowid,ID,value) VALUES(35,'1234',534);
INSERT INTO testTable(rowid,ID,value) VALUES(36,'1234',535);
INSERT INTO testTable(rowid,ID,value) VALUES(37,'1234',536);
INSERT INTO testTable(rowid,ID,value) VALUES(38,'1234',537);
INSERT INTO testTable(rowid,ID,value) VALUES(39,'1234',538);
INSERT INTO testTable(rowid,ID,value) VALUES(40,'1234',539);
INSERT INTO testTable(rowid,ID,value) VALUES(41,'1234',540);
INSERT INTO testTable(rowid,ID,value) VALUES(42,'1234',541);
INSERT INTO testTable(rowid,ID,value) VALUES(43,'1234',542);
INSERT INTO testTable(rowid,ID,value) VALUES(44,'1234',543);
INSERT INTO testTable(rowid,ID,value) VALUES(45,'1234',544);
INSERT INTO testTable(rowid,ID,value) VALUES(46,'1234',545);
INSERT INTO testTable(rowid,ID,value) VALUES(47,'1234',546);
INSERT INTO testTable(rowid,ID,value) VALUES(48,'1234',547);
INSERT INTO testTable(rowid,ID,value) VALUES(49,'1234',548);
INSERT INTO testTable(rowid,ID,value) VALUES(50,'1234',549);
INSERT INTO testTable(rowid,ID,value) VALUES(51,'1234',550);
INSERT INTO testTable(rowid,ID,value) VALUES(52,'1234',551);
INSERT INTO testTable(rowid,ID,value) VALUES(53,'1234',552);
INSERT INTO testTable(rowid,ID,value) VALUES(54,'1234',553);
INSERT INTO testTable(rowid,ID,value) VALUES(55,'1234',554);
INSERT INTO testTable(rowid,ID,value) VALUES(56,'1234',555);
INSERT INTO testTable(rowid,ID,value) VALUES(57,'1234',556);
INSERT INTO testTable(rowid,ID,value) VALUES(58,'1234',557);
INSERT INTO testTable(rowid,ID,value) VALUES(59,'1234',558);
INSERT INTO testTable(rowid,ID,value) VALUES(60,'1234',559);
INSERT INTO testTable(rowid,ID,value) VALUES(61,'1234',560);
INSERT INTO testTable(rowid,ID,value) VALUES(62,'1234',561);
INSERT INTO testTable(rowid,ID,value) VALUES(63,'1234',562);
INSERT INTO testTable(rowid,ID,value) VALUES(64,'1234',563);
INSERT INTO testTable(rowid,ID,value) VALUES(65,'1234',564);
INSERT INTO testTable(rowid,ID,value) VALUES(66,'1234',565);
INSERT INTO testTable(rowid,ID,value) VALUES(67,'1234',566);
INSERT INTO testTable(rowid,ID,value) VALUES(68,'1234',567);
INSERT INTO testTable(rowid,ID,value) VALUES(69,'1234',568);
INSERT INTO testTable(rowid,ID,value) VALUES(70,'1234',569);
INSERT INTO testTable(rowid,ID,value) VALUES(71,'1234',570);
INSERT INTO testTable(rowid,ID,value) VALUES(72,'1234',571);
INSERT INTO testTable(rowid,ID,value) VALUES(73,'1234',572);
INSERT INTO testTable(rowid,ID,value) VALUES(74,'1234',573);
INSERT INTO testTable(rowid,ID,value) VALUES(75,'1234',574);
INSERT INTO testTable(rowid,ID,value) VALUES(76,'1234',575);
INSERT INTO testTable(rowid,ID,value) VALUES(77,'1234',576);
INSERT INTO testTable(rowid,ID,value) VALUES(78,'1234',577);
INSERT INTO testTable(rowid,ID,value) VALUES(79,'1234',578);
INSERT INTO testTable(rowid,ID,value) VALUES(80,'1234',579);
INSERT INTO testTable(rowid,ID,value) VALUES(81,'1234',580);
INSERT INTO testTable(rowid,ID,value) VALUES(82,'1234',581);
INSERT INTO testTable(rowid,ID,value) VALUES(83,'1234',582);
INSERT INTO testTable(rowid,ID,value) VALUES(84,'1234',583);
INSERT INTO testTable(rowid,ID,value) VALUES(85,'1234',584);
INSERT INTO testTable(rowid,ID,value) VALUES(86,'1234',585);
INSERT INTO testTable(rowid,ID,value) VALUES(87,'1234',586);
INSERT INTO testTable(rowid,ID,value) VALUES(88,'1234',587);
INSERT INTO testTable(rowid,ID,value) VALUES(89,'1234',588);
INSERT INTO testTable(rowid,ID,value) VALUES(90,'1234',589);
INSERT INTO testTable(rowid,ID,value) VALUES(91,'1234',590);
INSERT INTO testTable(rowid,ID,value) VALUES(92,'1234',591);
INSERT INTO testTable(rowid,ID,value) VALUES(93,'1234',592);
INSERT INTO testTable(rowid,ID,value) VALUES(94,'1234',593);
INSERT INTO testTable(rowid,ID,value) VALUES(95,'1234',594);
INSERT INTO testTable(rowid,ID,value) VALUES(96,'1234',595);
INSERT INTO testTable(rowid,ID,value) VALUES(97,'1234',596);
INSERT INTO testTable(rowid,ID,value) VALUES(98,'1234',597);
INSERT INTO testTable(rowid,ID,value) VALUES(99,'1234',598);
INSERT INTO testTable(rowid,ID,value) VALUES(100,'1234',599);
COMMIT;
delete suc
----------------------------------------------
[alias]  co = clone --recurse-submodules  up = submodule update --init --recursiveupd = pullinfo = statusrest = reset --hard懒鬼提速https://www.cctry.com/>http://qalculate.github.io/downloads.htmlhttps://www.cctry.com/
作者:
男 biznow (biznow) ★☆☆☆☆ -
盒子活跃会员
2022/7/25 19:33:32
20楼: 我特意测试了一下,我的方法是使用unidac的unidump,测试时通过的,可以ddl到文件,也可以恢复到内存
----------------------------------------------
-
作者:
男 biznow (biznow) ★☆☆☆☆ -
盒子活跃会员
2022/7/25 19:41:59
21楼: unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, DADump, UniDump,
  UniProvider, SQLiteUniProvider, Data.DB, DBAccess, Uni, Vcl.Grids,
  Vcl.DBGrids, MemDS;

type
  TForm1 = class(TForm)
    UniConnection1: TUniConnection;
    SQLiteUniProvider1: TSQLiteUniProvider;
    UniDump1: TUniDump;
    Button1: TButton;
    UniQuery1: TUniQuery;
    UniQuery2: TUniQuery;
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    UniQuery3: TUniQuery;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  // 创建内存表
  UniQuery1.Close;
  UniQuery1.SQL.Clear;
  UniQuery1.SQL.Add('CREATE TABLE COMPANY(');
  UniQuery1.SQL.Add('   ID INT PRIMARY KEY     NOT NULL,');
  UniQuery1.SQL.Add('   NAME          TEXT    NOT NULL,');
  UniQuery1.SQL.Add('   AGE          INT     NOT NULL,');
  UniQuery1.SQL.Add('   ADDRESS        CHAR(50),');
  UniQuery1.SQL.Add('   SALARY         REAL');
  UniQuery1.SQL.Add(')');
  UniQuery1.Execute;
  // 查询临时数据
  UniQuery3.Close;
  UniQuery3.SQL.Clear;
  UniQuery3.SQL.Add('insert into company(id,name,age,address,salary)values(1,'#39'myname'#39',30,'#39'test add'#39', 100)');
  UniQuery3.Execute;
  // 查询,界面展示
  UniQuery2.Close;
  UniQuery2.SQL.Clear;
  UniQuery2.SQL.Add('select * from company');
  UniQuery2.Open;
  UniDump1.TableNames := 'company';
  UniDump1.BackupToFile('z:\company.sql');
  // 以下为company.sql的内容
  (*
    -- UniDAC version: 9.1.1
    -- SQLite server version: 3.8.10.2
    -- SQLite client version: 3.8.10.2
    -- Script date 25/07/2022 19:30:45
    -- ----------
    -- Server:
    -- Database: :memory:


    DELETE FROM company;
    INSERT INTO company VALUES (1, 'myname', 30, 'test add', 100);
  *)
end;

end.
----------------------------------------------
-
作者:
男 sxqwhxq (步惊云) ★☆☆☆☆ -
普通会员
2022/7/26 9:15:26
22楼: 是的,unidac只支持linux x86,不支持linux arm。
----------------------------------------------
-
作者:
男 keymark (嬲) ▲▲▲△△ -
普通会员
2022/7/26 11:08:36
23楼: 所以为啥不翻译C能用的代码 
是在等unidac 支持arm吗?
----------------------------------------------
[alias]  co = clone --recurse-submodules  up = submodule update --init --recursiveupd = pullinfo = statusrest = reset --hard懒鬼提速https://www.cctry.com/>http://qalculate.github.io/downloads.htmlhttps://www.cctry.com/
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行104.9805毫秒 RSS