浏览代码

Every code that interacts with database is saved in consumer folder

Jovian (Toshiba) 6 年之前
父节点
当前提交
a5431d1b47
共有 3 个文件被更改,包括 7 次插入4 次删除
  1. 4 4
      app_dispatcher.py
  2. 0 0
      consumer/connect.py
  3. 3 0
      consumer/credentials.py

+ 4 - 4
app_dispatcher.py

@@ -1,9 +1,9 @@
-from connect import DataConsumer
-
-credentials = "host=localhost dbname=logistics user=postgres password=postgres_password"
+from consumer.connect import DataConsumer
+from consumer.credentials import getCredentials
 
 print('Start')
 
+credentials = getCredentials()
 consumer = DataConsumer(credentials)
 
 rows = consumer.getProductSet()
@@ -11,4 +11,4 @@ rows = consumer.getProductSet()
 for r in rows:
 	print(r)
 
-print('End')
+print('End')

connect.py → consumer/connect.py


+ 3 - 0
consumer/credentials.py

@@ -0,0 +1,3 @@
+def getCredentials():
+    """ Return credentials for the database """
+    return "host=localhost dbname=logistics user=postgres password=postgres_password"