Power BI Refresh Error:
252006
What does this error mean?
An operation was attempted on a cursor object that has already been closed. Once cursor.close() is called, the cursor cannot be used for further query execution or result fetching.
Common causes
- 1Calling cursor.execute() or cursor.fetchall() after cursor.close() has been called
- 2Using a cursor after exiting a context manager (with conn.cursor() as cursor) that closes it automatically
- 3Cursor was closed due to connection.close() being called while the cursor was still in scope
- 4Reusing a cursor object stored in a module-level variable after the connection was recycled
- 5Multi-threaded code where one thread closes the cursor while another is still using it
How to fix it
- 1Create a new cursor for each query: use cursor = conn.cursor() before each operation.
- 2Use context managers and do all cursor operations inside the with block.
- 3Do not store cursor objects at module level — always create them from the active connection.
- 4In multi-threaded code, create separate cursors per thread or use a thread-safe connection pool.
- 5If using connection.close() as a cleanup step, ensure all cursors are finished before closing.
Frequently asked questions
Official documentation: https://github.com/snowflakedb/snowflake-connector-python/blob/main/src/snowflake/connector/errorcode.py