<commit_before>import sys
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
import yaml
import inspect
import os
from definitions import ENVIRONMENTS

Base = declarative_base()

# default_db_uri = {
# 		'test' : 'postgresql://halfdan:halfdan@localhost/tekrice_test',
# 		'dev' :	'postgresql://halfdan:halfdan@localhost/tekrice_dev',
# 		'prod' : 'postgresql://halfdan:halfdan@localhost/tekrice_prod'
# 			}



# CURRENT_ENVIRONMENT = 'dev'



class DBManager(object):

	def __init__(self, env):
		self.set_database_environment(env)

	def set_database_environment(self, env):
		assert env in ENVIRONMENTS
		self.env = env
		self.set_databases()
		self.__confdb__()

	def set_databases(self):
		dbconfig_path = 'db_config.yml'
		# dbconfig_path = '%s/db_config.yml'%'/'.join(__file__.split('/')[:-2])
		with open(dbconfig_path) as f:
			f = f.read()
			try:
				dbconfig = yaml.load(f)
			except Exception:
				print 'Could not parse db_config.yaml. Did you follow the instructions in the README? :)'
				sys.exit(1)

		username = dbconfig[self.env]['username']
		password = dbconfig[self.env]['password']
		dbname = dbconfig[self.env]['dbname']
		dbhost = dbconfig[self.env]['dbhost']
		self.dburi = 'postgresql://%s:%s@%s/%s'%(username, password, dbhost, dbname)<commit_msg>fixes bad path to db_config.yml<commit_after>from app import debug
import sys
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
import yaml
import inspect
import os
from definitions import ENVIRONMENTS

Base = declarative_base()

# default_db_uri = {
# 		'test' : 'postgresql://halfdan:halfdan@localhost/tekrice_test',
# 		'dev' :	'postgresql://halfdan:halfdan@localhost/tekrice_dev',
# 		'prod' : 'postgresql://halfdan:halfdan@localhost/tekrice_prod'
# 			}



# CURRENT_ENVIRONMENT = 'dev'



class DBManager(object):

	def __init__(self, env):
		self.set_database_environment(env)

	def set_database_environment(self, env):
		assert env in ENVIRONMENTS
		self.env = env
		self.set_databases()
		self.__confdb__()

	def set_databases(self):
		dbconfig_path = '/'.join(__file__.split('/')[:-2]) + '/db_config.yml' #Not pretty but it works for now. 
		debug(dbconfig_path)
		# dbconfig_path = '%s/db_config.yml'%'/'.join(__file__.split('/')[:-2])
		with open(dbconfig_path) as f:
			f = f.read()
			try:
				dbconfig = yaml.load(f)
			except Exception:
				print 'Could not parse db_config.yaml. Did you follow the instructions in the README? :)'
				sys.exit(1)

		username = dbconfig[self.env]['username']
		password = dbconfig[self.env]['password']
		dbname = dbconfig[self.env]['dbname']
		dbhost = dbconfig[self.env]['dbhost']
		self.dburi = 'postgresql://%s:%s@%s/%s'%(username, password, dbhost, dbname)
{'fraction_non_alphanumeric': 0.13636363636363635, 'fraction_numerical': 0.0017349063150589867, 'mean_word_length': 4.883673469387755, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2317457', 'n_tokens_mistral': 1122, 'n_tokens_neox': 1013, 'n_words': 210}