mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-23 11:39:55 +02:00
+ Added sqlitev3x direct api call test
ok under i386-win32 and arm-wince * updated sqlite3.pp sqlite3_libversion_number git-svn-id: trunk@1137 -
This commit is contained in:
parent
2c1901aeaa
commit
d60f16c069
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -1663,6 +1663,8 @@ packages/base/sqlite/sqlite.pp svneol=native#text/plain
|
||||
packages/base/sqlite/sqlite3.pp svneol=native#text/plain
|
||||
packages/base/sqlite/sqlitedb.pas svneol=native#text/plain
|
||||
packages/base/sqlite/test.pas svneol=native#text/plain
|
||||
packages/base/sqlite/testapiv3x.README -text
|
||||
packages/base/sqlite/testapiv3x.pp -text
|
||||
packages/extra/Makefile svneol=native#text/plain
|
||||
packages/extra/Makefile.fpc svneol=native#text/plain
|
||||
packages/extra/amunits/Makefile svneol=native#text/plain
|
||||
|
@ -286,7 +286,7 @@ function sqlite3_libversion:PChar;cdecl;external External_library name 'sqlite3_
|
||||
function sqlite3_version:PChar;cdecl;external External_library name 'sqlite3_libversion';
|
||||
|
||||
// Not published functions
|
||||
//function sqlite3_libversion_number:longint;cdecl;external External_library name 'sqlite3_libversion_number';
|
||||
function sqlite3_libversion_number:longint;cdecl;external External_library name 'sqlite3_libversion_number';
|
||||
//function sqlite3_key(db:Psqlite3; pKey:pointer; nKey:longint):longint;cdecl;external External_library name 'sqlite3_key';
|
||||
//function sqlite3_rekey(db:Psqlite3; pKey:pointer; nKey:longint):longint;cdecl;external External_library name 'sqlite3_rekey';
|
||||
//function sqlite3_sleep(_para1:longint):longint;cdecl;external External_library name 'sqlite3_sleep';
|
||||
|
40
packages/base/sqlite/testapiv3x.README
Normal file
40
packages/base/sqlite/testapiv3x.README
Normal file
@ -0,0 +1,40 @@
|
||||
Testing SQLite v3
|
||||
|
||||
This prog is a simple direct api call
|
||||
for sqlite v3x.
|
||||
|
||||
I.install
|
||||
1°)win32
|
||||
|
||||
sqlite3.dll should be in default path or current dir
|
||||
can be downloaded from here :
|
||||
http://www.sqlite.org/
|
||||
|
||||
|
||||
2°)wince-arm
|
||||
|
||||
sqlite3.dll should be in default path or current dir
|
||||
wince version can be downloaded from here :
|
||||
http://sourceforge.net/projects/sqlite-wince
|
||||
this is a source only release evc++4
|
||||
also pre-compiled libraries for arm-wince will put
|
||||
on ftp://ftp.freepascal.org/pub/fpc/contrib/cross/arm-wince-sqlite322.zip
|
||||
|
||||
II.tests
|
||||
|
||||
2005/09/19 :
|
||||
wince-arm :
|
||||
testapvv3x have been tested with v3.2.2
|
||||
compiled fpc2.1.1 today svn rep
|
||||
command line for cross-compiling from XP:
|
||||
ppcrossarm.exe -a -dNORMAL -Twince -XParm-wince-pe- -FDd:\binutils\win32-arm-pe -FE. -va -darm testapiv3x.pp >test-arm-wince.log
|
||||
|
||||
win32 :
|
||||
testapvv3x have been tested with v3.2.4
|
||||
compiled fpc2.1.1 today svn rep under lazarus
|
||||
|
||||
|
||||
|
||||
Regards
|
||||
olivier
|
||||
orinaudo@gmail.com
|
83
packages/base/sqlite/testapiv3x.pp
Normal file
83
packages/base/sqlite/testapiv3x.pp
Normal file
@ -0,0 +1,83 @@
|
||||
program testapiv3x;
|
||||
|
||||
{$APPTYPE CONSOLE}
|
||||
{$MODE DELPHI}
|
||||
|
||||
uses windows, sqlite3, sysutils;
|
||||
|
||||
const
|
||||
DBFILE='dbtest.db';
|
||||
|
||||
var
|
||||
rc : Integer;
|
||||
db : PPsqlite3;
|
||||
sql : string;
|
||||
pzErrMsg : PChar;
|
||||
|
||||
function MyCallback(_para1:pointer; plArgc:longint; argv:PPchar; argcol:PPchar):longint; cdecl;
|
||||
var i: Integer;
|
||||
PVal, PName: ^PChar;
|
||||
begin
|
||||
PVal:=argv;
|
||||
PName:=argcol;
|
||||
for i:=0 to plArgc-1 do begin
|
||||
writeln(Format('%s = ''%s'''#13, [PName^, PVal^]));
|
||||
inc(PVal);
|
||||
inc(PName);
|
||||
end;
|
||||
writeln(#13);
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
begin
|
||||
writeln(Format('SQLite version : %d',[sqlite3_libversion_number]));
|
||||
rc := sqlite3_open(PChar(DBFILE), @db);
|
||||
try
|
||||
if rc<>SQLITE_OK then begin
|
||||
writeln(Format('Can''t open database: %s',[DBFILE]));
|
||||
end;
|
||||
|
||||
sql:= 'DROP TABLE Test;';
|
||||
rc:=sqlite3_exec(db, PChar(sql), @MyCallback, nil, @pzErrMsg);
|
||||
if( rc<>SQLITE_OK )
|
||||
then writeln(Format('SQL error: %s', [pzErrMsg^]));
|
||||
|
||||
sql:='CREATE TABLE Test(No integer, name varchar(32),shortname varchar(32), age integer);';
|
||||
rc:=sqlite3_exec(db, PChar(sql), @MyCallback, nil, @pzErrMsg);
|
||||
if( rc<>SQLITE_OK )
|
||||
then writeln(Format('SQL error: %s', [pzErrMsg^]));
|
||||
|
||||
sql:='INSERT INTO Test VALUES(1,''hi'', ''by'', -1);';
|
||||
rc:=sqlite3_exec(db, PChar(sql), @MyCallback, nil, @pzErrMsg);
|
||||
Writeln('Inserting row');
|
||||
if( rc<>SQLITE_OK )
|
||||
then writeln(Format('SQL error: %s', [pzErrMsg^]));
|
||||
|
||||
SQL := 'INSERT INTO Test VALUES(2,''dualcore'', ''runwell'',-1);';
|
||||
rc:=sqlite3_exec(db, PChar(sql), @MyCallback, nil, @pzErrMsg);
|
||||
Writeln('Inserting row') ;
|
||||
if( rc<>SQLITE_OK )
|
||||
then writeln(Format('SQL error: %s', [pzErrMsg^]));
|
||||
|
||||
SQL := 'INSERT INTO Test VALUES(3,''Hello'', ''World'',NULL);';
|
||||
rc:=sqlite3_exec(db, PChar(sql), @MyCallback, nil, @pzErrMsg);
|
||||
Writeln('Inserting row') ;
|
||||
if( rc<>SQLITE_OK )
|
||||
then writeln(Format('SQL error: %s', [pzErrMsg^]));
|
||||
|
||||
SQL := 'INSERT INTO Test VALUES(4,''just a little'', ''test'',-1);';
|
||||
rc:=sqlite3_exec(db, PChar(sql), @MyCallback, nil, @pzErrMsg);
|
||||
Writeln('Inserting row') ;
|
||||
if( rc<>SQLITE_OK )
|
||||
then writeln(Format('SQL error: %s', [pzErrMsg^]));
|
||||
|
||||
SQL := 'select * from Test;';
|
||||
rc:=sqlite3_exec(db, PChar(sql), @MyCallback, nil, @pzErrMsg);
|
||||
if( rc<>SQLITE_OK )
|
||||
then writeln(Format('SQL error: %s', [pzErrMsg^]));
|
||||
finally sqlite3_close(db); end;
|
||||
|
||||
sleep(5000);
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user