Fortunately, on-line, there is no dual database, you can try to use the Select function without the from data table to implement the return value.
Some test code:
Try: Conn= Psycopg2.connect (Database=db.service_name, User=db.username, Password=password, Host=db.ip, port=db.port) Cursor=conn.cursor ()exceptException, E:context_dict= {'msg'E'Address': Db.ip,'Port': Db.port}returnRender (Request,'sar/release_info.html', context_dict) SQL="SELECT ' OK ' as txt" Try: Cursor.execute (SQL) x=cursor.fetchone () [0]exceptexception,e:context_dict= {'msg':"Password Authentication passed, but select function error",'Address': Db.ip,'Port': Db.port}returnRender (Request,'sar/release_info.html', Context_dict)finally: Cursor.close () conn.close ()ifx = ='OK': Context_dict= {'msg':"Database connection OK",'SQL': SQL,'Address': Db.ip,'Port': Db.port}returnRender (Request,'sar/release_info.html', context_dict)
How do I emulate Oracle's dual table in PostgreSQL to test the most basic connectivity capabilities of the database?