Page 1 of 1

Sqlite - ATTACH DATABASE

Posted: 30.09.2008, 12:04
by mariuszekpl
I have two databases:
dane.db and dane2.db

in dane.db i have table app_storage
in dane2.db i have table app_storage too :)

In ZConnection2: TZConnection; I open dane.db ;

I attach dane2.db to database dane.db:

Code: Select all

 path := ExtractFilePath(application.ExeName)  ;
  ZSQLProcessor1.Script.text :=  format( ' ATTACH DATABASE "%s\dane2.db" as dane2 ',[path]);
I open dane2.app_storage table (It is table app_storage from dane2.db)

But if i edit data in dane2.app_storage i edit data in app_storage (but in dane.db )

2008-09-30 10:41:38 cat: Execute, proto: sqlite-3, msg: SELECT * FROM dane2.app_storage

2008-09-30 10:41:38 cat: Execute, proto: sqlite-3, msg: PRAGMA table_info('app_storage')
2008-09-30 10:41:40 cat: Execute, proto: sqlite-3, msg: UPDATE "app_storage" SET "key"='22222' WHERE "id"=1
2008-09-30 10:41:41 cat: Execute, proto: sqlite-3, msg: UPDATE "app_storage" SET "key"='222222' WHERE "id"=2
2008-09-30 10:41:42 cat: Execute, proto: sqlite-3, msg: UPDATE "app_storage" SET "key"='2222222' WHERE "id"=3
2008-09-30 10:41:44 cat: Execute, proto: sqlite-3, msg: UPDATE "app_storage" SET "key"='222222222' WHERE "id"=4
But should be:
2008-09-30 10:41:38 cat: Execute, proto: sqlite-3, msg: SELECT * FROM dane2.app_storage

2008-09-30 10:41:38 cat: Execute, proto: sqlite-3, msg: PRAGMA table_info('dane2.app_storage')
2008-09-30 10:41:40 cat: Execute, proto: sqlite-3, msg: UPDATE "dane2.app_storage" SET "key"='22222' WHERE "id"=1
2008-09-30 10:41:41 cat: Execute, proto: sqlite-3, msg: UPDATE "dane2.app_storage" SET "key"='222222' WHERE "id"=2
2008-09-30 10:41:42 cat: Execute, proto: sqlite-3, msg: UPDATE "dane2.app_storage" SET "key"='2222222' WHERE "id"=3
2008-09-30 10:41:44 cat: Execute, proto: sqlite-3, msg: UPDATE "dane2.app_storage" SET "key"='222222222' WHERE "id"=4
procedure TZGenericCachedResolver.PostUpdates(Sender: IZCachedResultSet;
UpdateType: TZRowUpdateType; OldRowAccessor, NewRowAccessor: TZRowAccessor);

->

function TZGenericCachedResolver.FormUpdateStatement(Columns: TObjectList;
OldRowAccessor, NewRowAccessor: TZRowAccessor): string;

->

function TZGenericCachedResolver.DefineTableName: string;

->

function TZGenericCachedResolver.ComposeFullTableName(Catalog, Schema,
Table: string): string;


Of course i can use ZUpdateSQL to generate update SQL to edit dane2.app_storage table but better way should be correct zeos commponents :D

Small patch to add support attach database in sqlite

Posted: 30.09.2008, 22:41
by mariuszekpl
I fix it :)
In attachment file you can find my ZDbcSqLiteMetadata.pas

Posted: 01.10.2008, 09:23
by mdaems
Committed to SVN Testing Branch (rev. 478). I Intend to apply this to 6.6-patches branch as well.

Mark