SQLite 用の非常に単純な選択関数を作成しましたが、メンバー関数を渡す方法がわかりません。例: .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())
このメンバー関数を引数として渡すにはどうすればよいですか?