From 2d0004371aa43478fa09f31c51c1ace5b63c0806 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Thu, 18 Jul 2013 10:03:54 -0300 Subject: [PATCH] save the db file with the db settings (maybe I should put this in the app config and make a function to start the db) --- lyrics/db/__init__.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lyrics/db/__init__.py b/lyrics/db/__init__.py index b9840c2..f4f8e6c 100644 --- a/lyrics/db/__init__.py +++ b/lyrics/db/__init__.py @@ -1,7 +1,20 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- + +"""Database models and functions.""" + from datetime import date from pony.orm import * -db = Database("sqlite", "lyrics.sqlite", create_db=True) +import inspect +import os.path + +file_path = inspect.getsourcefile(self) +file_path = os.path.dirname(file_path) + +db = Database("sqlite", + os.path.join(file_path, "lyrics.sqlite"), + create_db=True) class Artist(db.Entity): name = Required(unicode)