2

Why are both a connection and a cursor needed in the Python database API specification? In the context of SQLite3 these objects seem redundant, as shown:

The main reason for the existence in SQLite3 of both connection and cursor objects seems to be compliance with the Python database API specification v2.0. This specification is applicable not just to SQLite interfaces such as SQLite3 but to a range of databases in Python. From a design perspective, why is it beneficial to differentiate between a connection and a cursor? Are there any conceptual or efficiency advantages?

user4157124
  • 2,809
  • 13
  • 27
  • 42
mgarort
  • 195
  • 8
  • You may have multiple cursors for one connection (maybe not for all DB implementations, don't know for Sqlite). – Michael Butscher Jul 27 '21 at 13:22
  • 1
    So the reason for this design would be to have more manual control over parallel access? (i.e. the user is free to create as many cursors as they would like). However, couldn't this also be done by creating multiple connections to the same database file? – mgarort Jul 27 '21 at 13:29
  • 2
    I can only guess that this would need more resources, like e. g. one network connection per db connection (for MySQL and similar larger dbs). – Michael Butscher Jul 27 '21 at 20:15

0 Answers0