Lost License Key?

Please keep me informed of Widget Press news, software updates and products.

Widget Press Privacy Policy

Browse Support

How To Connect To MySQL and Build

The following article describes how to connect your MySQL database to ModelBaker. It assumes you already have MySQL installed, you have already created a database with a user name "foo", password "bar" and database name "acme". It also assumes you know the file path to your mysql.sock file (created only when MySQL is running) and the command line file path to mysql executable.

  1. Create a new ModelBaker project and save it "acme.modelbaker".

    To get started, we need to have a project. Easy enough, simply select File -> New from the menu bar. You should see an empty project. Let's go ahead and save this project to our desktop and name it 'acme.modelbaker'. Save ModelBaker Project

  2. Set your user name, password and database name at the Database setting under the Settings Tab.

    When users visit our web application, we need a place to save and update all the information, this is what a database will do. Let's go ahead and add our database credentials to ModelBaker. Select the Settings Tab and select Database from the list to the left. Enter the user name, password and database credentials. Save your credentials

  3. Choose your Build Path folder from the Build Setting from the Settings Tab.

    Your build path should be the path for your local web server. A good place for the Mac is your Sites directory, located at '/Users/<you_user_name>/Sites' path. This examples uses '/Users/jonathan/Sites/acme' build path.

    Set your build path
  4. Add a 'Product' Entity Model (attributes w/ types if you like).

    Let's add a 'Product' model and add some attributes. ModelBaker will automatically generate table attributes (id,modified,created and any foreign keys) for you, so there is no need to add these attributes. Models are the foundation to our web application and they save the key information that makes up our web app.

    Add entity models
  5. Select "Drop and insert MySQL tables during build" at the Build Setting from the Settings Tab. Enter your MySQL bin path and your MySQL sock path.

    During our development, we want to see our changes take place in real time. Let's make sure we select "Drop and insert MySQL tables during build". Also, we need to tell ModelBaker where MySQL is (typically in a bin directory) and tell where our mysql.sock file is located. Select MySQL

  6. Save project, click "Build" button.

    Build your project

    Your project should be created to the build path you specified. Open the Finder and see the generated files. Your MySQL database should have an inserted 'products' table with any columns you have added.

    MySQL console

Last modified on January 05, 2009