If you want use PostgreSQL as database engine:
sudo apt install postgresql-server-dev-all postgresql postgresql-client
If you already use/know PostgreSQL, you can directly go to Test the database access.
Tracim uses the psycopg driver between the SQLAlchemy ORM and the PostgreSQL RDBMS. Run the following command to install the right version:
pip install -r install/requirements.postgresql.txt
Debian PostgreSQL stores connections authorization in /etc/postgresql/9.1/main/pg_hba.conf. Edit this file and check that connection from 127.0.0.1 are allowed using user/password. You should find the following line in the file:
# IPv4 local connections:
host all all 127.0.0.1/32 md5
If you changed the file, reload PostgreSQL:
service postgresql reload
You need a database and associated user/password. Tracim comes with pgtool, tool that will make this step easy:
./bin/pgtool help
Run the following self explanatory commands:
sudo su postgres
./bin/pgtool create_user tracimuser tracimpassword
./bin/pgtool create_database tracimdb
./bin/pgtool grant_all_privileges tracimdb tracimuser
exit
So, now you have a database and an associated user/password. A good habit is to test things before to use them, that's why we want to test the database access. This is easily done with Tracim pgtool:
./bin/pgtool test_connection tracimdb tracimuser tracimpassword 127.0.0.1
The result is similar to the following :
PG # CONNECT TO DATABASE
------------------------
server: 127.0.0.1
database: tracimdb
username: bibi
now
-------------------------------
2014-11-10 09:40:23.306199+01
(1 row)
In case of failure, you would get something like this:
PG # CONNECT TO DATABASE
------------------------
server: 127.0.0.1
database: tracimdb
username: bibi
psql: FATAL: password authentication failed for user "bibi"
FATAL: password authentication failed for user "bibi"
ERRROR
In this case, delete the user and database you previously created, using pgtool, and do it again. Do not forget to run the grant_all_rights command!
Or if you want to use MySQL as database engine
sudo apt install mysql-server
Tracim uses the PyMySQL driver between the SQLAlchemy ORM and the MySQL RDBMS. Run the following command to install the right version:
pip install -r install/requirements.mysql.txt
Connect to MySQL with root user (password has been set at "Installation" -> "Dependencies" chapter, when installing package)
mysql -u root -p
Create a database with following command:
CREATE DATABASE tracimdb;
Create a user with following command:
CREATE USER 'tracimuser'@'localhost' IDENTIFIED BY 'tracimpassword';
And allow him to manipulate created database with following command:
GRANT ALL PRIVILEGES ON tracimdb . * TO 'tracimuser'@'localhost';
Then flush privileges:
FLUSH PRIVILEGES;
You can now quit MySQL prompt:
\q
In the file tracim/development.ini, search the lines corresponding to the SQLAlchemy database url parameter sqlalchemy.url. SQLite is the default active database and others should be commented.
If you're willing to choose PostgreSQL or MySQL, comment the sqlalchemy.url line corresponding to SQLite and uncomment the one of your choice.
For example with PostgreSQL, this should gives you:
sqlalchemy.url = postgresql://tracimuser:tracimpassword@127.0.0.1:5432/tracimdb?client_encoding=utf8
# sqlalchemy.url = mysql+pymysql://tracimuser:tracimpassword@127.0.0.1/tracimdb
# sqlalchemy.url = sqlite:///tracimdb.sqlite
Proceed as above for the file tracim/tests.ini, except that you need to reproduce these steps three times for each of the following entries:
Again with PostgreSQL, this should gives you:
sqlalchemy.url = postgresql://tracimuser:tracimpassword@127.0.0.1:5432/tracimdb_test?client_encoding=utf8
# sqlalchemy.url = mysql+pymysql://tracimuser:tracimpassword@127.0.0.1/tracimdb_test
# sqlalchemy.url = sqlite:///tracimdb_test.sqlite
Note: Do not copy the lines from the file tracim/development.ini to the file tracim/tests.ini, the database names aren't the same.