0

I have a basic Python interface to a database, where what would be the "connection" class does the querying and retrieveing as well.

I was wondering whether it would make sense to write a dummy cursor() function inside that class as:

def cursor(self):
    return self

and then just implement fetch() et al. in the same class.

If it makes a difference, the goal is to connect the database with SQLAlchemy.

Jay
  • 2,535
  • 3
  • 32
  • 44
  • I guess the answer might possibly be probably yes (or no), except how'd you handle SQLA or the like calling `close()` on your "cursor", which is actually your connection object. What about multiple concurrent cursors? – Ilja Everilä Aug 23 '17 at 06:01
  • I initially figured I'd use a local variable like `is_cur_open` to track "closing". Second question - I guess that would've called for opening another connection instance, as there is no cursor concurrency really – Jay Aug 23 '17 at 16:12

0 Answers0