aboutsummaryrefslogtreecommitdiff
blob: 21258593abef56ce7be01be16a9eb470a6b4cf3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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)