Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. DATABASES = {
  2. 'db2': {
  3. 'ENGINE' : 'ibm_db_django',
  4. 'NAME' : 'SAMPLE',
  5. 'USER' : 'USERNAME',
  6. 'PASSWORD' : 'TOPSECRET',
  7. 'HOST' : 'localhost',
  8. 'PORT' : '50000',
  9. 'PCONNECT' : False, #Optional property, by default it is false
  10. }
  11. }
  12.  
  13. try:
  14. db2_cursor = connections['db2'].cursor()
  15. except Exception, e:
  16. db2_cursor = False
  17. logger.error("db2-connection failure: %s" % e)
  18.  
  19.  
  20. def get_from_db2(search_id):
  21. sql_query = settings.DB2_SQLQUERY % search_id
  22.  
  23. if not db2_cursor:
  24. logger.info(u"DB2 - no connection")
  25. return None
  26.  
  27. db2_cursor.execute(sql_query)
  28.  
  29. # do stuff
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement