It is currently Mon May 01, 2017 3:44 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Mysql Connection
PostPosted: Sat Apr 15, 2017 11:19 am 
Offline
New User
New User

Joined: Sat Apr 15, 2017 11:16 am
Posts: 1
Hello,

i have programmed andy Windows Programms with Purebasic with Mysql Connect..

Now i try to Programm this on My new Mac an the Database connection ist not working.

i tryed ODBC and mysql.pbi from this Forum, nothing Working...

can anyone halp me?


Top
 Profile  
Reply with quote  
 Post subject: Re: Mysql Connection
PostPosted: Sat Apr 15, 2017 3:45 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 771
Location: Germany
I have the same problem with mysql driver. It´s a architecture failure...

This can help... viewtopic.php?f=12&t=56390

Ups... Not ready all.
Look under '/usr/local' is driver installed. Perhaps you must change the path and name to the driver

Actuel drivers on https://dev.mysql.com/downloads/connector/c/

P.S. Works with new MySQl driver. Change mysql.pbi to
Code:
...
CompilerCase #PB_OS_MacOS
        If Path_To_MySQL_Lib = ""
          CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
            Path_To_MySQL_Lib = "/usr/local/mysql-connector-c-6.1.9-macos10.12-x86_64/lib/libmysqlclient.18.dylib"
            ;Path_To_MySQL_Lib = "/usr/local/mysql-connector-c-6.1.6-osx10.8-x86_64/lib/libmysqlclient.18.dylib"
          CompilerElse
            Path_To_MySQL_Lib = "/usr/local/mysql-connector-c-6.1.9-macos10.12-x86/lib/libmysqlclient.18.dylib"
            ;Path_To_MySQL_Lib = "/usr/local/mysql-connector-c-6.1.6-osx10.8-x86/lib/libmysqlclient.18.dylib"
          CompilerEndIf 
         EndIf
         MySQL_Lib = OpenLibrary(#PB_Any, Path_To_MySQL_Lib)
         If MySQL_Lib = 0
            MySQL_Lib = OpenLibrary(#PB_Any, "libmysqlclient.dylib")
         EndIf
...     


Example
Code:
;-TOP

IncludeFile "mysql.pbi"

UseMySQLDataBase()

Procedure CheckDatabaseUpdate(Database, Query$)
  Result = DatabaseUpdate(Database, Query$)
  If Result = 0
    Debug DatabaseError()
  EndIf
 
  ProcedureReturn Result
EndProcedure

database.s = "host=server port=3306 dbname=developer"
user.s = "developer"
pass.s = "purebasic"

If OpenDatabase(0, database, user, pass, #PB_Database_MySQL)
  CheckDatabaseUpdate(0, "CREATE TABLE food (name CHAR(50), weight INT)")
 
  CheckDatabaseUpdate(0, "INSERT INTO food (name, weight) VALUES ('apple', '10')")
  CheckDatabaseUpdate(0, "INSERT INTO food (name, weight) VALUES ('pear', '5')")
  CheckDatabaseUpdate(0, "INSERT INTO food (name, weight) VALUES ('banana', '20')")
 
  If DatabaseQuery(0, "SELECT * FROM food WHERE weight > 5")
    While NextDatabaseRow(0)
      Debug GetDatabaseString(0, 0)
    Wend
    FinishDatabaseQuery(0)
  EndIf
 
  CloseDatabase(0)
Else
  Debug "Can't open database !"
  CallDebugger
EndIf

_________________
My Projects OOP-BaseClass / OOP-BaseClassDispatch / Event-Designer /
PB v3.30 / v5.60 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye