Problem with SQLite - need help

Mac OSX specific forum
User avatar
michel51
Enthusiast
Enthusiast
Posts: 290
Joined: Mon Nov 21, 2005 10:21 pm
Location: Germany

Problem with SQLite - need help

Post 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.
michel51

Mac OS X Snow Leopard (10.6.8 ) Intel
PureBasic V 5.21(x64), V 5.22beta
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Post 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
User avatar
michel51
Enthusiast
Enthusiast
Posts: 290
Joined: Mon Nov 21, 2005 10:21 pm
Location: Germany

Post 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.
michel51

Mac OS X Snow Leopard (10.6.8 ) Intel
PureBasic V 5.21(x64), V 5.22beta
CSAUER
Enthusiast
Enthusiast
Posts: 188
Joined: Mon Oct 18, 2004 7:23 am
Location: Germany

Post 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.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PB4.1 - Win: MacBook black 2008 2,4 GHz, 4 GB RAM, MacOSX 10.5/VMWare/WinXP
PB4.1 - Mac: MacMini G4 1,4 GHz, 512 MB RAM, MacOSX 10.4
User avatar
michel51
Enthusiast
Enthusiast
Posts: 290
Joined: Mon Nov 21, 2005 10:21 pm
Location: Germany

Post 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.
michel51

Mac OS X Snow Leopard (10.6.8 ) Intel
PureBasic V 5.21(x64), V 5.22beta
Post Reply