# Project configuration

## Database connection

* If you do not have access to a remote database server or want to run it locally, go to [index](index.md) for information on setting up the database server.

Suppose that you intend to work on a project named `foo` use the terminal to navigate to the project directory:

```bash
cd foo


```

To log into the database you need the `host`, the `database name`, the `user` name, and the `password`.
Note, the selected user needs at least read access on the selected database (True? maybe also write?).

The root of the fishbook package contains a file called *template_dj_local_conf.json*. copy this file to your project folder, i.e. the location from which you call your scripts, remove the `template_` prefix and fill in `database.host`, `database.user`, `database.password`.

The json template looks like this:

```json
{
    "database.host": "yourhost",
    "database.user": "yourdatabaseusername",
    "database.password": "yourdatabaseuserpassword",
    "database.port": 3306,
    "loglevel": "DEBUG",
    "display.width": 14,
    "display.limit": 7,
    "safemode": false,
    "connection.init_function": null
}
```

### Example

Let's assume you are working remotely, i.e. connecting to a remote database on a server that has the name ```foo.uni-xyz.de```. The database is up and running and allows connections via port 3306 (the default). The database is called ```fish_db``` and the user credentials are name ```baz``` and password ```bar```. The configuration file will look like this:

```json
{
    "database.host": "foo.uni-xyz.de",
    "database.user": "bar",
    "database.password": "baz",
    "database.port": 3306,
    "loglevel": "DEBUG",
    "display.width": 14,
    "display.limit": 7,
    "safemode": false,
    "connection.init_function": null
}
```

In case you are working with a local database the ```database.host``` entry is ```"localhost"```.
If you ommit ```database.user``` or ```database.password``` fishbook, respectively datajoint, will ask you for the user credentials every time you run your python scripts.

**IMPORTANT:** This configuration file is pure text and can be easily read by anyone. It **must not** be part of a public repository. **Do not add it to your version control system!**