Statistics
| Branch: | Tag: | Revision:

root / README.DB @ 92c53da1

History | View | Annotate | Download (3.3 kB)

1
*** SQLite
2

    
3
Django configuration in ettings.py:
4

    
5
	PROJECT_PATH = os.path.dirname(os.path.abspath(__file__)) + '/'
6

    
7
	DATABASES = {
8
	    'default': {
9
		'ENGINE': 'sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
10
		# ATTENTION: This *must* be the absolute path if using sqlite3.
11
		# See: http://docs.djangoproject.com/en/dev/ref/settings/#name
12
		'NAME': PROJECT_PATH + 'database.sqlite'                      # Or path to database file if using sqlite3.
13
	    }
14
	}
15

    
16
Database initialization:
17
	[the following commands assume the DB is at "./database.sqlite"]
18

    
19
		recreate db, load db/fixtures/initial_data.json:
20

    
21
		$ rm database.sqlite
22
		$ bin/python manage.py syncdb
23

    
24
		load fixtures, as necessary [take a look under db/fixtures/]:
25

    
26
		$ bin/python manage.py loaddata db/fixtures/flavors.json
27
		$ bin/python manage.py loaddata db/fixtures/vms.json
28
		...
29

    
30
*** MySQL
31

    
32
Django configuration in settings.py:
33

    
34
	DATABASES = {
35
	    'default': {
36
		'ENGINE': 'mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
37
		# ATTENTION: This *must* be the absolute path if using sqlite3.
38
		# See: http://docs.djangoproject.com/en/dev/ref/settings/#name
39
		'NAME': 'synnefo',                      # Or path to database file if using sqlite3.
40
		'USER': 'USERNAME',                      # Not used with sqlite3.
41
		'PASSWORD': 'PASSWORD',                   # Not used with sqlite3.
42
		'HOST': 'HOST',                # Set to empty string for localhost. Not used with sqlite3.
43
		'PORT': 'PORT',                         # Set to empty string for default. Not used with sqlite3.
44
		# Have MySQL use InnoDB as the storage engine for newly created tables
45
		'OPTIONS': {
46
		    'init_command': 'SET storage_engine=INNODB',
47
		}
48
	    }
49
	}
50

    
51
Server setup [not necessary for client operation]:
52

    
53
	a) Install MySQL server, set password for user 'root'
54
	b) Modify /etc/mysql/my.cnf to bind on public IP if you want to allow
55
	   allow connections from foreign hosts.
56
	c) Create database:
57

    
58
	$ mysql -u root -p
59

    
60
	mysql> create database synnefo;
61
	mysql> show databases;
62
	mysql> GRANT ALL on synnefo.* TO username IDENTIFIED BY 'password';
63

    
64
Client setup:
65

    
66
	d) Install the MySQL client
67
	# apt-get install libmysqlclient-dev
68
	$ bin/pip install MySQL-python
69

    
70
	libmysqlclient-dev provides mysql_config, otherwise installing MySQL-python fails with:
71
		EnvironmentError: mysql_config not found
72

    
73
*** PostgreSQL
74

    
75
Django configuration in settings.py:
76

    
77
	DATABASES = {
78
	    'default': {
79
		'ENGINE': 'postgresql_psycopg2', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
80
		# ATTENTION: This *must* be the absolute path if using sqlite3.
81
		# See: http://docs.djangoproject.com/en/dev/ref/settings/#name
82
		'NAME': 'DATABASE',                      # Or path to database file if using sqlite3.
83
		'USER': 'USERNAME',                      # Not used with sqlite3.
84
		'PASSWORD': 'PASSWORD',                  # Not used with sqlite3.
85
		'HOST': 'HOST',                # Set to empty string for localhost. Not used with sqlite3.
86
		'PORT': 'PORT',                         # Set to empty string for default. Not used with sqlite3.
87
	    }
88
	}
89

    
90
Client setup:
91

    
92
	# apt-get install postgresql-client-8.4
93

    
94
	attempt a connection:
95
	$ psql -h HOST -p PORT -U USERNAME
96

    
97
	# apt-get install libpq-dev
98
	$ bin/pip install psycopg2
99