Luca Olivetti wrote:
Hello,
I'm writing an embedded application that will need a small database (no more than a couple thousand records), and I though sqlite could do it. It probably won't have any graphical interface, so I don't need all the goodies of a TDataset descendant, OTOH I like some other things a dataset will buy me. Needless to say, the application must be rock solid, running unattended 24/7. I made a quick test with the sqlite3ds component that's included in lazarus and with SQLitePass http://source.online.free.fr/ I dropped either dataset in a form with a datasource and a dbgrid (as suggested in the wiki). My first impression (and as every first impression may just be wrong) is tha sqlite3ds doesn't work well with a dbgrid, because it doesn't automatically update the underlying database and so it doesn't catches exceptions when you, e.g, try to insert a duplicate. What's worse, when I call ApplyUpdates it silently discards the data (I would have expected at least an exception, but I see that there's no exception raised and neither an event is called in case of errors in TCustomSqliteDataset.ApplyUpdates).
The behavior is by design (follows KISS philosophy).

- Update on post: sqliteds keeps the records in memory, works with them (add,update,delete) and than send the changes to the database when the user decides (more or less like sqldb). To update the database each time a change occurs add ApplyUpdates in the OnPost event.

- ApplyUpdates error handling: Error is handled just does not follows the exception model. Check if ApplyUpdates is false. If so check ReturnCode (see sqlite docs for values) and ReturnString values.

- Primary key handling: sqliteds automatically handles primary key in two ways. First add a AutoInc field to the table (Using FieldDefs.Add/CreateTable) and sqliteds will ensure it will always be unique and not null without user intervention. Second, if you have a integer field as primary key set AutoIncrementKey to true and PrimaryKey to the field name.
If the primary key is not integer the user must handle it yourself.
SQLitePass seems more solid (again, only with this simple test), since it automatically updates the database and raises an exception immediately if I try to insert a duplicate key. OTOH it raises a RunError(204) when I close the form.

Pros of sqlite3ds:
- included in lazarus
- author active on this mailing list
- ...?

Cons of sqlite3ds:
- incomplete (?) implementation
Sure.
- doesn't really check errors
See above.
- ...?
- Undocumented features (to be fixed soon)

PS: I would recommend version from fpc 214 which has a lot of bug fixes.

Luiz

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to