aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPriit Laes <plaes@plaes.org>2010-07-01 00:25:38 +0300
committerPriit Laes <plaes@plaes.org>2010-07-01 00:25:38 +0300
commit4a626e62de7df4d1285483dd547dcf0be1ef966a (patch)
tree18d0c93e25f2bcfd90ab2a0693868ae667373651
parentAdd support for package removal (diff)
downloadgsoc2010-grumpy-4a626e62de7df4d1285483dd547dcf0be1ef966a.tar.gz
gsoc2010-grumpy-4a626e62de7df4d1285483dd547dcf0be1ef966a.tar.bz2
gsoc2010-grumpy-4a626e62de7df4d1285483dd547dcf0be1ef966a.zip
Added database glue code and added short installation tutorial
-rw-r--r--README30
-rw-r--r--grumpy/database.py26
2 files changed, 53 insertions, 3 deletions
diff --git a/README b/README
index acc516b..3f8b922 100644
--- a/README
+++ b/README
@@ -1,3 +1,4 @@
+==============
Project Grumpy
==============
@@ -5,7 +6,7 @@ Project Grumpy is a maintainer-oriented set of tools for handling various
developer-related metadata.
Requirements
-------------
+============
- Python-2.5+
- pkgcore
@@ -23,6 +24,29 @@ Database configuration is defined by specifying the RFC-1738 style uri::
Installation
-------------
+============
+
+Please not that database configuration is currently hardcoded to use
+PostgreSQL database named 'grumpy' on localhost using 'grumpy:grumpy' as
+credentials. This will be fixed in future ;)
+
+So the first step you need to do, is to give access to user 'grumpy' using
+password 'grumpy' to database called 'grumpy' on your local machine.
+
+To setup the app, you need to populate database with proper schema. So fire
+up the python interpreter in the root directory of grumpy project:
+
+ $ python
+ >>> from grumpy.database import init_db
+ >>> init_db()
+
+If no errors were shown schema creation was successful :)
+
+Now, to populate database with portage data, there's an utility inside 'utils'
+directory called 'grumpy_sync.py'. All you have to do for now is to give a
+path to portage directory as first argument:
+
+ $ python utils/grumpy_sync.py /usr/portage
-TBD.
+And now go and fetch yourself a glass of cold milk because this initial sync
+will take a while.
diff --git a/grumpy/database.py b/grumpy/database.py
new file mode 100644
index 0000000..2125859
--- /dev/null
+++ b/grumpy/database.py
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+"""
+ grumpy.database
+ ~~~~~~~~~~~~~~~
+
+ This module contains high-level database glue for the application.
+
+ :copyright: (c) by 2010 Priit Laes.
+ :license: BSD, see LICENSE for details.
+"""
+from grumpy.models import Base
+
+from sqlalchemy import create_engine
+from sqlalchemy.orm import scoped_session, sessionmaker
+
+# FIXME: Hardcoded ;)
+engine = create_engine('postgresql://grumpy:grumpy@localhost/grumpy')
+session = scoped_session(sessionmaker(autocommit=False,
+ autoflush=False,
+ bind=engine))
+
+def init_db():
+ Base.metadata.create_all(bind=engine)
+
+def drop_db():
+ Base.metadata.drop_all(bind=engine)