【发布时间】:2012-06-07 08:08:13
【问题描述】:
我为 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())
如何将此成员函数作为 arg 传递?
【问题讨论】:
标签: python sqlite select functional-programming pysqlite