aboutsummaryrefslogtreecommitdiff
path: root/examples/example_02.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/example_02.py')
-rw-r--r--examples/example_02.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/examples/example_02.py b/examples/example_02.py
new file mode 100644
index 0000000..2844121
--- /dev/null
+++ b/examples/example_02.py
@@ -0,0 +1,57 @@
1#!/usr/bin/env python
2# Copyright (C) 2010 Leonard Thomas
3#
4# This file is part of dodai.
5#
6# dodai is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# Foobar is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with dodai. If not, see <http://www.gnu.org/licenses/>.
18
19
20##############################################################################
21# The following is for setting up the correct python path. Ignore this
22# section for your project
23import sys
24import os.path as p
25path = p.dirname(p.dirname(p.abspath(__file__)))
26sys.path.append(path)
27##############################################################################
28
29"""
30This example requires that you have sqlalchemy installed as well as the
31psycopg2 package.
32
33On ubuntu you can do:
34 apt-get install libpq-dev
35 easy_install psycopg2
36 easy_install sqlalchemy
37
38"""
39
40
41from dodai.config import Config
42
43
44def main(config):
45 print config.db.__dict__
46
47
48if __name__ == "__main__":
49
50 config = Config()
51 path = p.join(p.dirname(p.abspath(__file__)), 'config')
52 config.files().set_directory(path)
53 config.files().load('config.cfg')
54 config.dbs().add_config(config_parser=config.files().parser())
55 db = config.dbs().load('test_db')
56 config.set('db', db)
57 main(config())