views:

586

answers:

2

I am creating application for MAC using cocoa framework, I would like to know how and what are the ways i can connect to MySql database using cocoa framework.

A: 

Short answer: You can't, at least not directly.

The Cocoa Framework doesn't have a database driver, generic or otherwise (CoreData notwithstanding). In order to connect to a mysql database you need to use the aptly named libmysqlclient. This library is not included with Xcode, and as such will have to be downloaded (and probably built) separately: You can get it from here.

You'll probably have to distribute the library with your application, license issues might result.

Edit: It seems as if a library for connecting to the mysql database should be installed together with a MySQL server install. If the application will only need to run on machines where MySQL is installed, you might get away with linking to this.

Williham Totland
Thank you for your reply,I found out about cocoa-mysql objective-c framework but its not working well. If i get it working will post back few things with it so some one can use it!Thanks again!
A: 

You might want to look into http://www.sequelpro.com/docs/Source_Code. They seem to have resurrected the original MySQL-Cocoa code and it seems to be under active development. The other option is the commercial MacSQL Framework.

Edit: You might also want to look at the following tutorial. It is a great introduction in using the libmysqlclient and even provides a sample Xcode project.

Alex Winston
Thanks Alex,I managed with sequal pro code yesterday just after asking question here. I got the source code and extracted MCPKit which is working perfectly fine with my app. Right now i am looking forward to adding fetched data in to nstableview.If you need any thing with this library will be happy to give you the extracted lib as there is no much support for mysql cocao objective-c. Or we can build up on this library and have it for all who needs it.thanks again! ;)