-
Notifications
You must be signed in to change notification settings - Fork 1
/
demo.py
33 lines (27 loc) · 1.06 KB
/
demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import json
from ConfigParser import SafeConfigParser
from myrabbit_py import MyRabbitPublisher
def main():
# reading configuration file
parser = SafeConfigParser()
parser.read('config.ini')
# rabbit connection parameters
rabbit_url = str(parser.get('rabbitmq', 'rabbit_url'))
# mysql connection parameters
mysql_url = str(parser.get('mysql', 'mysql_url'))
mysql_username = str(parser.get('mysql', 'mysql_username'))
mysql_psw = str(parser.get('mysql', 'mysql_psw'))
mysql_dbname = str(parser.get('mysql', 'mysql_dbname'))
mysql_table_list = json.loads(str(parser.get('mysql', 'mysql_table_list')))
myrabbitpublisher = MyRabbitPublisher(rabbit_url,
mysql_url,
mysql_username,
mysql_psw,
mysql_dbname,
mysql_table_list)
try:
myrabbitpublisher.run()
except KeyboardInterrupt:
myrabbitpublisher.stop()
if __name__ == '__main__':
main()