Python Database connection Close

前端 未结 5 937
一个人的身影
一个人的身影 2021-01-30 03:57

Using the code below leaves me with an open connection, how do I close?

import pyodbc
conn = pyodbc.connect(\'DRIVER=MySQL ODBC 5.1 driver;SERVER=localhost;D         


        
5条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-30 04:42

    You might try turning off pooling, which is enabled by default. See this discussion for more information.

    import pyodbc
    pyodbc.pooling = False
    conn = pyodbc.connect('DRIVER=MySQL ODBC 5.1 driver;SERVER=localhost;DATABASE=spt;UID=who;PWD=testest') 
    
    csr = conn.cursor()  
    csr.close()
    del csr
    

提交回复
热议问题