Why close the cursor for Sqlite3 in Python

Is there any use to closing the cursor when using the Python sqlite3 module ? Or is it just an artifact of DB API v2.0 that can do something useful only for other databases?

It makes sense that connection.close () frees up resources; however, it is not clear what exactly cursor.close () does, whether it really frees up some resource or does nothing. The documents for him are uninformed:

>>> import sqlite3
>>> conn = sqlite3.connect(':memory:')
>>> c = conn.cursor()
>>> help(c.close)
Help on built-in function close:

close(...)
    Closes the cursor.

Note that this is a completely different question than Why do you need to create a cursor when querying the sqlite database? . I know what cursors are for. The question is what the cursor.close () method actually does and is there any use for calling it.

+6
source share
1 answer

In the case of SQLite, there is not much difference, but the database API is designed not only for embedded databases, but for all SQL databases.

For DBMS, the cursor often implies a session in the client, and sometimes on the server.

, Python (, CPython), , GC .

0

Source: https://habr.com/ru/post/1017190/


All Articles