Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [mysql]
- host = localhost
- database = python_mysql
- user = root
- password =
- def read_db_config(filename='config.ini', section='mysql'):
- parser = ConfigParser()
- parser.read(filename)
- db = {}
- if parser.has_section(section):
- items = parser.items(section)
- for item in items:
- db[item[0]] = item[1]
- else:
- raise Exception('{0} not found in the {1} file'.format(section, filename))
- return db
- ...
- conn = mysql.connector.connect(host='localhost',
- database='python_mysql',
- user='root',
- password='secret')
- ...
Add Comment
Please, Sign In to add comment