mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-06 10:07:54 +02:00
* Patch from Reinier to test library loader for SQlite
git-svn-id: trunk@27343 -
This commit is contained in:
parent
dbf13fc77a
commit
48a7259ec3
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -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
|
||||
|
60
packages/fcl-db/examples/sqlite3loadlib.lpr
Normal file
60
packages/fcl-db/examples/sqlite3loadlib.lpr
Normal 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.
|
Loading…
Reference in New Issue
Block a user