bash pip install txpostgres python from twisted.internet import reactor from twisted.internet.defer import inlineCallbacks from txpostgres import txpostgres python conn_pool = txpostgres.ConnectionPool( host="localhost", port=5432, database="mydatabase", user="myuser", password="mypassword" ) python @inlineCallbacks def execute_query(): conn = yield conn_pool.connect() try: result = yield conn.runQuery("SELECT * FROM mytable") print(result) finally: python if __name__ == "__main__": execute_query() reactor.run()


上一篇:
下一篇:
切换中文