* Patch from Reinier to test library loader for SQlite

git-svn-id: trunk@27343 -
This commit is contained in:
michael 2014-03-29 18:43:28 +00:00
parent dbf13fc77a
commit 48a7259ec3
2 changed files with 61 additions and 0 deletions

1
.gitattributes vendored
View File

@ -1988,6 +1988,7 @@ packages/fcl-db/examples/fbeventstest.pp svneol=native#text/plain
packages/fcl-db/examples/loadlibdemo.lpi svneol=native#text/plain
packages/fcl-db/examples/loadlibdemo.pp svneol=native#text/plain
packages/fcl-db/examples/pqeventstest.pp svneol=native#text/plain
packages/fcl-db/examples/sqlite3loadlib.lpr svneol=native#text/plain
packages/fcl-db/fpmake.pp svneol=native#text/plain
packages/fcl-db/src/Dataset.txt svneol=native#text/plain
packages/fcl-db/src/README.txt svneol=native#text/plain

View File

@ -0,0 +1,60 @@
program sqlite3loadlib;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes, sysutils,
sqldb,
sqldblib, sqlite3conn;
var
LibLoader: TSQLDBLibraryLoader;
Conn: TSQlite3Connection;
Tran: TSQLTransaction;
Q: TSQLQuery;
Existed: boolean;
begin
LibLoader:=TSQLDBLibraryLoader.Create(nil);
try
LibLoader.ConnectionType:='SQLite3';
LibLoader.LibraryName:='d:\auxinst\sqlite\sqlite3.dll';
LibLoader.Enabled := true;
LibLoader.LoadLibrary;
finally
LibLoader.Free;
end;
Conn:=TSQlite3Connection.create(nil);
try
Tran:=TSQLTransaction.create(nil);
Q:=TSQLQuery.Create(nil);
Conn.DatabaseName:='test.sqlite';
existed:=fileexists(conn.databasename);
Conn.Transaction:=Tran;
Q.DataBase:=Conn;
Conn.Open;
Tran.StartTransaction;
if not(existed) then
begin
// create test table
Conn.ExecuteDirect('create table test (id integer, name varchar(255))');
end;
Q.SQL.Text:='select id,name from test ';
Q.Open;
Q.Last; //force recordcount update
writeln('recordcount: '+inttostr(q.RecordCount));
Tran.Commit;
Q.Close;
Conn.Close;
finally
Q.Free;
Tran.Free;
Conn.Free;
//LibLoader.Free;
end;
writeln('Program complete. Press a key to continue.');
readln;
end.