Giter Site home page Giter Site logo

fcobia / just-mysql-example-mac-app-objective-c-xcode Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thrivesmart/just-mysql-example-mac-app-objective-c-xcode

0.0 2.0 0.0 3.11 MB

Example of how to easily get mysqlclient running inside your own Mac App, in XCode.

just-mysql-example-mac-app-objective-c-xcode's Introduction

How this app was created

  1. Download the latest tar from http://dev.mysql.com/downloads/mysql/

You should end up with something like: mysql-connector-c-6.1.2-osx10.7-x86_64

  1. Drag libmysqlclient.a into your project

Inside the lib folder, you'll see the file libmysqlclient.a. Drag that from the finder into your project, and include it in the Target (main app)

  1. Drag mysql.h and other header files into your project

Working through compiler errors, I determined that these are the required files, some of which are in include, include/mysql, and include/mysql/psi:

  • psi_base.h
  • psi_memory.h
  • my_alloc.h
  • typelib.h
  • plugin_auth_common.h
  • mysql.h
  • mysql_com.h
  • mysql_time.h
  • mysql_version.h
  • client_plugin.h
  • my_list.h
  1. Add libc++.dylib to your project.

Click on the topmost item of the project, so you can select your application target. In "Linked Frameworks and Libraries", click the + button, and search for libc++.dylib. In the confirmation, make sure the target is selected.

  1. Add 4 MySQLKit*.* files to your project.

Drag them into XCode from the finder:

  • MySQLKitDatabase.h
  • MySQLKitDatabase.m
  • MySQLKitQuery.h
  • MySQLKitQuery.m
  1. Implement your own database code somewhere
    MySQLKitDatabase* db = [[MySQLKitDatabase alloc] init];
    db.socket = @"/tmp/mysql/mysql.sock";
    db.serverName = @"localhost";
    db.dbName = @"sampledb";
    db.userName = @"root";
    db.password = @"12345";
    db.port = 8889;
    @try{
        [db connect];
        MySQLKitQuery *query = [[MySQLKitQuery alloc] initWithDatabase:db];
        query.sql = @"select * from table1 order by id";
        [query execQuery];
        NSInteger len = query.recordCount;
        for(NSInteger i = 0; i < len; i++){
            NSInteger id1 = [query integerValFromRow:i Column:0];
            NSString *stringV1 = [query stringValFromRow:i Column:1];
            //...
        }
    }
    @catch (NSException *exception) {
        // ...
        [db errorMessage];
    }
  1. You should be off to the races now!

Note: credit to http://macbug.org/macosxsample/mysql for helping get us off the ground!

just-mysql-example-mac-app-objective-c-xcode's People

Contributors

crowdmatt avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.