I've written a very simple select function for SQLite, but I'm confused at how to pass a member function... e.g.: .fetchone()
, .fetchmany()
.
def select(cursor, select="*", table="reuters", fetch=".fetchone()", tologfile=False, logfile=""):
if tologfile:
logfile = open(logfile, 'w')
logfile.write(str(cursor.execute("select * from ?;".replace('?',table).replace("select * ", "select "+select)).fetchone()))
logfile.close()
else: return str(cursor.execute("select * from ?;".replace('?',table).replace("select * ", "select "+select)).fetchone())
How do I pass this member function as an arg?