[fpc-pascal] Use of TSQLite.Query method (sqlite3db unit)

Maurizio Tomasi maurizio.tomasi at outlook.com
Fri Nov 7 14:03:15 CET 2014


Hi Joost and Reinier (sorry for the typo),

> Well, even in that case using Lazarus is possible. But what I do when I only have console-access is using the 'old-style'-Freepascal IDE. (fp) That's somewhat easier then vi when you are working on Pascal-files.

Sure, I didn't say it is impossible, only that it is not the best option 
in my case. I tried to use the FPIDE (I have used Turbo Pascal for 
years, from 3.0 through 7.0, and the FPIDE environment is thus very 
familiar to me), but I find Vim more productive, despite the fact that 
its Delphi mode is quite limited.

> In your case I would use the TSQLite3Dataset. SQLDB is overkill for most Sqlite-usage. And you can have a look at the fpc-sources for an example. You can find a nice example in packages/fcl-db/src/sqlite/testds.pas. (http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/packages/fcl-db/src/sqlite/testds.pas?view=markup)

I think I'll follow your advice. And thanks for the link, it seems 
exactly what I need!

At this point I wonder what is the intended usage of the "sqlite3db" 
unit: is anybody using it, apart from me?

> No it doesn't - what makes you think that? (So I can if needed update
> the relevant wiki page/sentence)

Sorry, I just *assumed* that. In the wiki page you linked 
(http://wiki.freepascal.org/SQLite) the example program under section 
"Using the SQLdb components with SQLite / Creating a database" and 
noticed that it used a variable SQLite3Connection1 and a variable 
SQLTransaction1 with no apparent connection between them (judging from 
the code fragment), so I assumed that such connection between the two 
objects was meant to be done using the Lazarus GUI. But reading 
carefully, I found the sentence "TSQLite3Connection can be found in the 
sqlite3conn unit, if you want to declare it yourself or are working in 
FreePascal", which settles the matter.

> You can e.g. adapt the minimal FPC demo code from here:
> http://wiki.lazarus.freepascal.org/Database_bug_reporting#FreePascal
>
> The advantage of this approach is that switching to another db engine
> such as PostgreSQL or Firebird is fairly simple (you'd still need to
> rewrite db dependent SQL of course).

Thanks a lot for the link, but I think I'll follow Joost' advice and use 
TSQLite3Dataset: I do not foresee to use any other database than SQLite3 
for the kind of app I'm developing.

   Maurizio.



More information about the fpc-pascal mailing list