import os
import sys
-import codecs
-import ConfigParser
+import yaml
import MySQLdb as db
# find config file and zipcode csv file
-config_filename = 'config.ini'
+config_filename = 'pypsd.yml'
if not os.path.exists(config_filename):
config_filename = os.path.join('..', config_filename)
if not os.path.exists(config_filename):
- print "We cannot locate the pypsd/pyva config.ini file"
+ print "We cannot locate the configuration file pypsd.yml"
print 'This script should be run from the root acid/ directory'
exit(1)
debug = '--debug' in sys.argv
# config
-config = ConfigParser.ConfigParser()
-config.readfp(codecs.open(config_filename, 'r', 'utf8'))
+with open(config_filename, "r") as config_fd:
+ config = yaml.load(config_fd)
# make db pointer
dbx = db.connect(
- host=config.get('database', 'host'),
- user=config.get('database', 'user'),
- passwd=config.get('database', 'passwd'),
- db=config.get('database', 'db'),
- unix_socket=config.get('database', 'sock')
+ host=config.get('database').get('host'),
+ user=config.get('database').get('user'),
+ passwd=config.get('database').get('passwd'),
+ db=config.get('database').get('db'),
)
dbx.autocommit(True) # no need to have transactions
dbp = dbx.cursor()