Discussion:
[Lazarus] SQLdb_Tutorial3 error
Santiago A. via Lazarus
2018-03-08 15:07:46 UTC
Permalink
Hello:

I'm trying to "SQLdb_Tutorial3" example with sqlite3 connector. When the
program executes Fquery.open it raises a SIGSEGV exception.

sqlite3.dll is in the same directory that the binary. I have created the
table employee, just in case. I don't know what else to check.  I can't
debug anything else, the debug can't enter in "open" method.

Any hint?

Windows 7 32 bits, Lazarus 1.8.0 SVN: 56594, fpc 3.0.4
--
Saludos

Santiago A.

--
leledumbo via Lazarus
2018-03-08 19:42:59 UTC
Permalink
Post by Santiago A. via Lazarus
Any hint?
Code please. Zipped project directory (use Publish Project feature) is OK if
single file example is not possible.



--
Sent from: http://free-pascal-lazarus.989080.n3.nabble.com/
--
Santiago A. via Lazarus
2018-03-09 09:41:49 UTC
Permalink
Post by leledumbo via Lazarus
Post by Santiago A. via Lazarus
Any hint?
Code please. Zipped project directory (use Publish Project feature) is OK if
single file example is not possible.
I will zip it, but sure you have it. The code is one of the examples
installed with the standard lazarus 1.8.0

In windows: <lazarusdir>\examples\database\sqldbtutorial3\

Error in mainform.pas line 221, using sqlite connector
--
Saludos

Santiago A.
Santiago A. via Lazarus
2018-03-10 11:23:57 UTC
Permalink
Post by Santiago A. via Lazarus
Post by leledumbo via Lazarus
Post by Santiago A. via Lazarus
Any hint?
Code please. Zipped project directory (use Publish Project feature) is OK if
single file example is not possible.
I will zip it, but sure you have it. The code is one of the examples
installed with the standard lazarus 1.8.0
In windows: <lazarusdir>\examples\database\sqldbtutorial3\
Error in mainform.pas line 221, using sqlite connector
Any suggestion of what could be wrong? Where to look?
Any hint?
--
Saludos

Santiago A.

--
Rik van Kekem via Lazarus
2018-03-12 12:41:47 UTC
Permalink
Post by Santiago A. via Lazarus
sqlite3.dll is in the same directory that the binary. I have created the
table employee, just in case. I don't know what else to check.  I can't
debug anything else, the debug can't enter in "open" method.
Creating the database and table employee wasn't "just in case".
It was a requirement if you want to use that example with sqlite.
http://wiki.lazarus.freepascal.org/SQLdb_Tutorial3#Getting_database_data_into_normal_controls

And surely you changed something (like the .ini) otherwise you end up
with Firebird db connection.

So zipping your project (with the database) is still best.

Tip: You are sure sqlite3.dll has the same 'bitness' (i.e. 32 of 64 bit)
as your executable?

Rik
--
Santiago A. via Lazarus
2018-03-13 09:43:13 UTC
Permalink
Post by Rik van Kekem via Lazarus
Post by Santiago A. via Lazarus
sqlite3.dll is in the same directory that the binary. I have created the
table employee, just in case. I don't know what else to check.  I can't
debug anything else, the debug can't enter in "open" method.
Creating the database and table employee wasn't "just in case".
It was a requirement if you want to use that example with sqlite.
I mean "Just in case" not to get the TStringGrid properly filled, but to
get an exception like "Table not found", not a "SIGSEGV exception"
Post by Rik van Kekem via Lazarus
http://wiki.lazarus.freepascal.org/SQLdb_Tutorial3#Getting_database_data_into_normal_controls
That is the piece of code that raises the error, in the line "Fquery.open"
Post by Rik van Kekem via Lazarus
And surely you changed something (like the .ini) otherwise you end up
with Firebird db connection.
No, the default is still firebird, and it woks fine. Well, it doesn't
work because employee doesn't exits, and I get an "Database not found
exception"
I select on propose sqlite3. and I get SIGSEGV  with no more clue in the
Fquery.open
Post by Rik van Kekem via Lazarus
So zipping your project (with the database) is still best.
Tip: You are sure sqlite3.dll has the same 'bitness' (i.e. 32 of 64
bit) as your executable?
Well, it is the dll I use for some old delphi 32bits utilities.

My point is if I'm missing some package, or the dll should be in other
path, or a hint how to dig and debug deeper, beacuse I can't debug into
open.
--
Saludos

Santiago A.
Rik van Kekem via Lazarus
2018-03-13 10:30:33 UTC
Permalink
Post by Santiago A. via Lazarus
My point is if I'm missing some package, or the dll should be in other
path, or a hint how to dig and debug deeper, beacuse I can't debug into
open.
No, the SQLite3.dll and your DB should be sufficient.

Could you include your .ini file and your SQLite db?

Normally the firebird employee database is in
C:\Program Files\Firebird\Firebird_2_5\examples\empbuild\EMPLOYEE.FDB
(which you can copy to another location so you can access it)

But for SQLite you'll need to create your own DB with the correct table
and content.

Rik
--
Santiago A. via Lazarus
2018-03-13 11:22:44 UTC
Permalink
Post by Rik van Kekem via Lazarus
Post by Santiago A. via Lazarus
My point is if I'm missing some package, or the dll should be in other
path, or a hint how to dig and debug deeper, beacuse I can't debug into
open.
No, the SQLite3.dll and your DB should be sufficient.
Could you include your .ini file and your SQLite db?
Normally the firebird employee database is in
C:\Program Files\Firebird\Firebird_2_5\examples\empbuild\EMPLOYEE.FDB
(which you can copy to another location so you can access it)
But for SQLite you'll need to create your own DB with the correct
table and content.
Rik
Thanks. Finally it works. I created the table employee and set the full
path of the file.

Nevertheless, it looks that sqlite3 is a little... well... sending
SIGSEGV is not a valid error, "cant' find file", "table doesn't exits"
etc would be much better.

I would like to dig a little and try to improve error detection. Is
there any way I can debug into open?. I've tried compiling Lazarus IDE
with debug, but skips over "open" call. What should I compile in debug
mode to parse FQuery.open?
--
Saludos

Santiago A.

--
Rik van Kekem via Lazarus
2018-03-13 11:46:05 UTC
Permalink
Post by Santiago A. via Lazarus
Thanks. Finally it works. I created the table employee and set the full
path of the file.
Nevertheless, it looks that sqlite3 is a little... well... sending
SIGSEGV is not a valid error, "cant' find file", "table doesn't exits"
etc would be much better.
I would like to dig a little and try to improve error detection. Is
there any way I can debug into open?. I've tried compiling Lazarus IDE
with debug, but skips over "open" call. What should I compile in debug
mode to parse FQuery.open?
I take it you already activated the debugging options (which were
disabled in your published project). Otherwise you wouldn't even be able
to trace to the Open line.

Next problem is that the database sources are not part of the Lazarus
IDE. They are from FPC. So you would need to recompile the complete FPC
to be able to step through it. (Recompiling Lazarus IDE only compiles
the IDE part with debugging information)

I use the trunk version from my own script but you could use fpcupdeluxe
to install a development version, in which you could trace through the
whole source. http://wiki.freepascal.org/fpcupdeluxe

Here, I get the correct and expected warnings/errors when using the
SQLite3 driver (in both Lazarus 1.9 and 1.8.2). SQLite will
automatically create an empty database if it does not exist. After that
it should warn about the absence of the employee table.

--
Rik
--

Loading...