[fpc-pascal] Cross-platform lightweight/fpc SQLite bindings?

Luiz Américo pascalive at bol.com.br
Tue Oct 25 19:09:27 CEST 2005


Alan Mead wrote:
> I just want some fairly light-weight sqlite3 bindings that work on
> Linux and Windows.  The code on the SQLite website works great on
> Windows but fails to compile on Linux.  (I don't know Windows API
> calls... it looks like he's searching for a function name in the
> DLL.) 

Are you failling to compile the sqlite library itself or the fpc binding 
(sqlite3.pas)?
The fpc binding does not depend of an other library except the sqlite itself

> I've tried a few other solutions and they have either not worked
> cross-platform or they are meant for Delphi and I couldn't compile
> them using just FPC.  
> 
> [I could use Lazarus... Is it easy to learn to use TDataSet?  My
> ideal would be something like Perl's DBI... prepare(), execute(),
> fetch_row(), etc.  I know SQL and don't need a lot of abstractions
> getting in the way.]

Yes it is. I recommend read any Delphi TDataset tutorial before using 
the fpc one if you are not familiar with it. Then if you choose to use 
TSqliteDatset take a look at lazarus wiki at Database/Sqlite section.

You can use TDataset also in console apps. See the examples in the dir 
http://svn.freepascal.org/svn/fpc/branches/fixes_2_0/fcl/db/sqlite/
Just rename from TSqliteDataset to TSqlite3dataset and sqliteds to 
sqlite3ds.

> Before I try to debug one of these non-working-solutions, does anyone
> know of an existing FPC (not Delphi/Lazarus) solution that works on
> both Windows and Linux?

At the time i tested, both the binding and the TDataset were working in 
Linux and Windows, but were a change in the binding later. I'll take a look.

You can find the newest units for sqlite3 in the svn repository:

base sqlite3 (binding):
http://svn.freepascal.org/svn/fpc/branches/fixes_2_0/packages/base/sqlite/sqlite3.pp

TDataset descendants
http://svn.freepascal.org/svn/fpc/branches/fixes_2_0/fcl/db/sqlite/customsqliteds.pas
http://svn.freepascal.org/svn/fpc/branches/fixes_2_0/fcl/db/sqlite/sqliteds3.pas

Luiz



More information about the fpc-pascal mailing list