Difference between revisions of "UMCD"

From The Battle for Wesnoth Wiki
(Installation)
(Database setup)
Line 17: Line 17:
  
 
===Database setup===
 
===Database setup===
 +
 +
====Initialize the MySQL database====
 +
 +
Enter the MySQL prompt with:
 +
 +
  mysql -u root -p
 +
 +
Then, we create the database:
 +
 +
  mysql> CREATE DATABASE IF NOT EXISTS umcd;
 +
  mysql> USE umcd;
 +
 +
We create the tables:
 +
 +
  mysql> source {wesnoth-directory}/data/umcd/database/create_database.sql
 +
 +
We populate the database:
 +
 +
  mysql> source {wesnoth-directory}/data/umcd/database/populate_database.sql
 +
 +
You can check that the tables are added with:
 +
 +
  mysql> show tables;
 +
 +
Now we quit the mysql prompt:
 +
 +
  mysql> exit;
 +
 +
====Add the database to ODBC====
 +
 +
We must link the database to ODBC, so we'll retrieve the database connexion via a Data source name (DSN).
 +
 +
First we must find the odbc.ini file:
 +
 +
  odbcinst -j
 +
 +
In my computer it's in /etc/odbc.ini so I'll refer to this location. We must edit this file:
 +
 +
  sudo vim /etc/odbc.ini
 +
 +
The file can be empty, we'll add these data:
 +
 +
  ;
 +
  ;  odbc.ini configuration for Connector/ODBC
 +
  ;
 +
 +
  [ODBC Data Sources]
 +
  dbumcd    = MyODBC Driver DSN for the UMCD database
 +
 +
  [dbumcd]
 +
  Driver      = /usr/lib/libmyodbc.so
 +
  Description  = Connector/ODBC Driver DSN for the UMCD database
 +
  SERVER      = localhost
 +
  PORT        =
 +
  USER        =
 +
  Password    =
 +
  Database    = umcd
 +
  OPTION      = 3
 +
  SOCKET      =
 +
 +
The DSN of the umcd database will be "dbumcd". You can change the SERVER and PORT entry if it's an external database. Otherwise, let all the fields with a blank like in the example.
 +
 +
Next we must install the driver with:
 +
 +
  odbcinst -f /etc/odbc.ini -d -i
 +
 +
You can list all the ODBC drivers installed with:
 +
 +
  odbcinst -s -q
 +
 +
That's all!
  
 
==Configuration==
 
==Configuration==

Revision as of 11:26, 17 August 2013

User Made Content Daemon (UMCD)

This page will give information on the UMCD.

Installation

Dependencies on Linux

We must first install some required packets:

 sudo apt-get install mysql-server unixodbc-dev libmyodbc libboost-iostreams-dev libboost-program-options-dev libboost-regex-dev libboost-system-dev libboost-thread-dev libboost-date-time-dev
  • mysql-server is the MySQL database.
  • unixodbc is a middleware API to access database (see http://en.wikipedia.org/wiki/ODBC).
  • libmyodbc is the MySQL driver to access the MySQL database.
  • Boost libraries are used to ease the development.

Database setup

Initialize the MySQL database

Enter the MySQL prompt with:

 mysql -u root -p

Then, we create the database:

 mysql> CREATE DATABASE IF NOT EXISTS umcd;
 mysql> USE umcd;

We create the tables:

 mysql> source {wesnoth-directory}/data/umcd/database/create_database.sql

We populate the database:

 mysql> source {wesnoth-directory}/data/umcd/database/populate_database.sql

You can check that the tables are added with:

 mysql> show tables;

Now we quit the mysql prompt:

 mysql> exit;

Add the database to ODBC

We must link the database to ODBC, so we'll retrieve the database connexion via a Data source name (DSN).

First we must find the odbc.ini file:

 odbcinst -j

In my computer it's in /etc/odbc.ini so I'll refer to this location. We must edit this file:

 sudo vim /etc/odbc.ini

The file can be empty, we'll add these data:

 ;
 ;  odbc.ini configuration for Connector/ODBC
 ;
 [ODBC Data Sources]
 dbumcd     = MyODBC Driver DSN for the UMCD database
 [dbumcd]
 Driver       = /usr/lib/libmyodbc.so
 Description  = Connector/ODBC Driver DSN for the UMCD database
 SERVER       = localhost
 PORT         =
 USER         =
 Password     =
 Database     = umcd
 OPTION       = 3
 SOCKET       =

The DSN of the umcd database will be "dbumcd". You can change the SERVER and PORT entry if it's an external database. Otherwise, let all the fields with a blank like in the example.

Next we must install the driver with:

 odbcinst -f /etc/odbc.ini -d -i

You can list all the ODBC drivers installed with:

 odbcinst -s -q

That's all!

Configuration