forked from RHODA-lab/rhoda-qa-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb_binding.py
More file actions
18 lines (17 loc) · 849 Bytes
/
db_binding.py
File metadata and controls
18 lines (17 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Libraries
import psycopg2
from pyservicebinding import binding
# DB Binding Function
def db_bind(args_dict):
print(args_dict)
print(args_dict.get('type'))
print(args_dict.get('provider'))
try:
sb = binding.ServiceBinding()
except binding.ServiceBindingRootMissingError as msg:
# log the error message and retry/exit
print("SERVICE_BINDING_ROOT env var not set")
#bindings_list = sb.bindings("postgresql", "Red Hat DBaaS / Crunchy Bridge")
bindings_list = sb.bindings(args_dict.get('type'), args_dict.get('provider'))
print(bindings_list)
return {'DB Binding': 'success', 'user': bindings_list[0].get('username') , 'password': bindings_list[0].get('password') , 'database': bindings_list[0].get('database') , 'host': bindings_list[0].get('host'), 'port': bindings_list[0].get('port')}