Using mysql with cocoa

Discussion in 'Mac Programming' started by Samppaa, Jul 4, 2010.

  1. Samppaa macrumors regular

    Mar 26, 2010
    I would need to use mysql with cocoa for my app and found only the outdated version of some library, what would you guys recommend? Is there any new ones possibly because I read that OS X doesn't support mysql already.
  2. xStep macrumors 68000

    Jan 28, 2003
    Less lost in L.A.
    I was just at the site and see server is support to OS 10.6 and the C Connector is supported to 10.5 which likely will work on 10.6. Downloads are here;
  3. larkost macrumors 6502a

    Oct 13, 2007
    A few notes:

    - MacOS X client does not have MySQL client or server installed by default, nor is it an option from the install disc. MacOS X Server has both. You can install both client and server code yourself, and they seem to be well supported.

    - There have been a few Obj-C libraries out there, but none of them seems to get much beyond the beta stage before their developers give up. At least this is my impression.

    - If you use the MySQL client libraries in your app then you MUST make your app GPL if you are going to distribute it. Or you can pay the MySQL group for a client license. Those are your only options.

    - If your app is going to need to have a local database, and does not access a database across a network, then MySQL is most likely the wrong choice and either SQLite or CoreData. Those solutions do not require setting up a complicated server on client workstations. They also happen to have easier licensing requirements (ie: just about none).

    - If you are looking for something really that complex, but have licensing issues with the GPL, then you should probably look at PostgreSQL. It is arguably better than SQL in almost any regards, and is BSD licensed.
  4. robbieduncan Moderator emeritus


    Jul 24, 2002
    Or you make a non-GUI executable that is linked to the MySQL client libraries and make that GPL. Then your proprietary, non-GPL, GUI app can start an instance of that executable and talk to it via distributed objects.
  5. Samppaa thread starter macrumors regular

    Mar 26, 2010
    Is there any license friendly alternatives for mysql? With mac connector please, as I am making mac program which uses it. I just need database where my client programs can get info from..
  6. garethlewis2 macrumors 6502

    Dec 6, 2006
    SQLite. It's not opensource, it\s public domain, so you don't need to pay a license fee, but, there's always a but somewhere; this does not apply to Germany which has bonkers rules. Germany does not believe in public domain, so you need to buy a license for SQLite from Dr Richard Hipp, about $10,000. Don't need this license anywhere else.

    Or you could do the simple thing that robbieDuncan posted and split your program into two parts. Create a shared API between the two that does not use the database, and have the non-gui portion of the application 'wrap' the MySQL C connector. You will only need to wrap a few simple functions. One to create/get a connection. Ones to execute statements, depending on whether they are updates/deletes/inserts or selects. Some simple ones to Start a transaction, and another to commit a transaction. Those simple ones shouldn't take more than a few days of work to get right, and the C connector will come with plenty of examples.

    Hope that helps.
  7. Samppaa thread starter macrumors regular

    Mar 26, 2010
  8. Cromulent macrumors 603


    Oct 2, 2006
    The Land of Hope and Glory
    PostgreSQL. It is BSD licensed so you can include any part of it you like in commercial applications, all you need to do is include a copyright notice and a disclaimer (read the license).

    Edit: Sorry didn't see your second post.

    Yes it is worth trying out. It is arguably a better database system than MySQL with better SQL standards support and simpler approach (no need for multiple storage engines for instance). Plus the documentation is about the best you will find in any computer software product.
  9. Samppaa thread starter macrumors regular

    Mar 26, 2010
    Can I use it in cocoa I mean postgre sql and put server on my windows computer.
  10. GorillaPaws macrumors 6502a


    Oct 26, 2003
    Richmond, VA

    Take a look at PostgreSQL for Mac. They have a Framework that's an Objective-C bridge to Postgres called PGSQLKit. It's BSD licensed.

    An alternative for working with PostgreSQL and Cocoa is the BaseTen framework. It's not free for commercial apps, but the license is only $200/developer. It allows you to access Postgres much like Core Data using a model builder. It's really neat and worth running through the tutorial.
  11. Karl Kraft macrumors newbie

    Jul 9, 2010
    Mysql and Objective-C

    The library I wrote along with usage notes is available at:

    Like all software it could certainly use a few more features, but as of now it is in production use on multiple projects. I have been using it for the last 2 years, with the most recent source change in early June to back port some items to the PPC version of the source.

Share This Page