Commit aca25b4c36c9d6d08a4e33f0eb64ac1bf571317f
- Diff rendering mode:
- inline
- side by side
check_feeds.py
(16 / 4)
|   | |||
| 34 | 34 | """ | |
| 35 | 35 | ||
| 36 | 36 | # Connect to database | |
| 37 | db_host = 'localhost' #192.168.2.180 | ||
| 38 | db_name = 'feeds' | ||
| 39 | db_user = 'feeds' | ||
| 40 | db_passwd = 'qtHB85cSzSLW6ppP' | ||
| 37 | db_settings_path = os.path.dirname(__file__) + '/config.txt' | ||
| 38 | if not os.path.isfile(db_settings_path): | ||
| 39 | print 'ERROR: Please create config.txt for db settings' | ||
| 40 | exit() | ||
| 41 | |||
| 42 | db_settings = {} | ||
| 43 | for line in open(db_settings_path): | ||
| 44 | if not line.startswith(('#', '//')): | ||
| 45 | setting = line.strip().split(' ',1) | ||
| 46 | db_settings[setting[0]] = setting[1] | ||
| 47 | |||
| 48 | db_host = db_settings['db_host'] | ||
| 49 | db_name = db_settings['db_name'] | ||
| 50 | db_user = db_settings['db_user'] | ||
| 51 | db_passwd = db_settings['db_passwd'] | ||
| 52 | |||
| 41 | 53 | conn = MySQLdb.Connection(host=db_host, db=db_name, user=db_user, | |
| 42 | 54 | passwd=db_passwd, charset='utf8') | |
| 43 | 55 | cursor = conn.cursor() |
config_sample.txt
(4 / 0)
|   | |||
| 1 | db_host localhost | ||
| 2 | db_name orator | ||
| 3 | db_user joesmith | ||
| 4 | db_passwd thisisespeciallysecret |

