Page 1 of 1

Problem with SQLite - need help

Posted: Wed Oct 03, 2007 9:21 am
by michel51
I will learn more SQLite and understand the handling and more.
But if I was running the following code, the file "testDB" ist created, but it's empty.
And the SQLite Data Browser says: "..not a SQLite DataBase"

Code: Select all

EnableExplicit
XIncludeFile "SQLite3_Include.pbi"

Define.l hDB, r, i, sqlhdl
Define.SQ3_TABLEMAP Table

If SQLiteInit() = 0
  MessageRequester("Error", "Couldn't init SQLite3 lib") : End
EndIf
;
; Debug SQLiteLibVersion()      ; 3.1.3
;
hDB = SQLiteOpen("testDB.db")
If Not hDB
  MessageRequester("Error", SQliteErrorMsg(hDB)) : End
EndIf

If SQliteExecute(hDB, "CREATE TABLE testtable (spalte1 TEXT, spalte2 TEXT, spalte3 TEXT)") = #FALSE
  Debug SQliteErrorMsg(hDB)
Else
  For r = 1 To 5
    If SQliteExecute(hDB, "INSERT INTO testtable (spalte1, spalte2, spalte3) VALUES ('r" + Str(r) + "c1', 'r" + Str(r) + "c2', 'r" + Str(r) + "c3')") = #FALSE
      Debug SQliteErrorMsg(hDB)
    EndIf
  Next
EndIf


SQLiteClose(hDB)
SQLiteEnd()
I don't know, what happens.
The code and the include are postings from here.
Is there a bug? Or is the code wrong? Or is my lib an old one (3.1.3)

Hope an Mac user can help.

Posted: Wed Oct 03, 2007 9:58 am
by Progi1984
For MacOS, you doesn't use the SQLite.lib, but the dylib placed here : /usr/lib/libsqlite3.dylib.

See this include :
http://www.purebasic.fr/english/viewtopic.php?t=27036

Posted: Wed Oct 03, 2007 11:24 am
by michel51
Progi1984 wrote:For MacOS, you doesn't use the SQLite.lib, but the dylib placed here : /usr/lib/libsqlite3.dylib.

See this include :
http://www.purebasic.fr/english/viewtopic.php?t=27036
I use the Mac-lib "libsqlite3.dylib", no other lib available.
And I use the include you named.
In this include the Mac lib is detected with CompilerIf.
The lib is opened correctly because I can get the version number for example.

Posted: Mon Oct 08, 2007 12:39 pm
by CSAUER
Try to analyze the db with my sqlite-tool:
http://www.purebasic.fr/english/viewtopic.php?t=28719

It has a experimental Mac OS X version included. This uses the same sources as you. So it should work fine.
Alternatively you can create a new db file with that tool as well.

Posted: Wed Oct 10, 2007 3:10 pm
by michel51
CSAUER wrote:Try to analyze the db with my sqlite-tool:
http://www.purebasic.fr/english/viewtopic.php?t=28719
But there is NO database to analyse :!:
As I posted above the file is created but it's empty.
So your tool cannot find a database.

BTW I use this SQLite Database Browser
http://sqlitebrowser.sourceforge.net
Alternatively you can create a new db file with that tool as well.
With your tool I cannot create a new db. There's a message "unsupported file format".
I will send you a few screenshots with other "bugs" within the Mac Version. The readfile will be in german (that's what I can better than english :) ), but I have to write that in the next hours.