X-Git-Url: https://jfr.im/git/irc/rizon/acid.git/blobdiff_plain/e02c451f090a20ca4a7de24e0dc69707582e7e38..refs/remotes/origin/acid/command:/pyva/populate-zipcodes.py diff --git a/pyva/populate-zipcodes.py b/pyva/populate-zipcodes.py index 0b7a160..f598d2f 100755 --- a/pyva/populate-zipcodes.py +++ b/pyva/populate-zipcodes.py @@ -4,16 +4,15 @@ 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) @@ -32,16 +31,15 @@ drop_table = '--drop' in sys.argv 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()