Table of Contents
A MySQL implementation of the TodoList
Clone the TodoList MySQL repository
git clone https://github.com/IBM-Swift/TodoList-MySQL.git
Install and start MySQL
brew install mysql brew link mysql mysql.server start
sudo apt-get install clang-3.8 lldb-3.8 libmysqlclient-dev mysql-server sudo service mysql start
Link MySQL during swift build
swift build -Xswiftc -I/usr/local/include/mysql -Xlinker -L/usr/local/lib -Xswiftc -DNOJSON
-I tells the compiler where to find the MySQL header files, and -L tells the linker where to find the library. This is required to compile and run on macOS.
swift build -Xswiftc -DNOJSON
Create your database table:
CREATE DATABASE todolist; USE todolist; CREATE TABLE todos (tid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, title TEXT, owner_id VARCHAR(256), completed INT, orderno INT);
Open the TodoList Client
Deploying to Bluemix:
Deploy to Bluemix Button
You can use this button to deploy TodoList to your Bluemix account, all from the browser. The button will create the application, create and bind any services specified in the manifest.yml file and deploy.
To finish, you need to setup the database by following the instructions below starting with step 3.
Create the service
cf create-service cleardb spark TodoList-MySQL
Push your application if you haven't already
Note: The uploading droplet stage should take several minutes. If it worked correctly, it should say:
1 of 1 instances running App started
The application will automatically bind to your ClearDB database.
If you already have pushed your application, you can bind the service:
cf bind-service TodoList-MySQLApp Todo-MySQL cf restage TodoList-MySQL
Get your credentials for the ClearDB database:
cf env TodoList-MySQL
Note the username, password, and hostname.
Create your database table from the command line with the following commands:
mysql -u <username> -p -h <hostname>
You’ll be prompted for your password
Look for the database name that was assigned for you. For example, it will look similiar to: "ad_ec426ec34c4e649".
use <database name>; CREATE TABLE todos (tid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, title TEXT, owner_id VARCHAR(256), completed INT, orderno INT);
Compile and run tests:
- Ensure MySQL is running and the scheme is populated from the quick start instructions above.
Run the tests:
swift test -Xswiftc -I/usr/local/include/mysql -Xlinker -L/usr/local/lib -Xswiftc -DNOJSON
swift test -Xswiftc -DNOJSON