看似不必要的python sql类
我在python中遇到一个函数,它说:看似不必要的python sql类,python,sql,function,Python,Sql,Function,我在python中遇到一个函数,它说: class _Sqlite3Cursor(object): def __init__(self, cursor): self.cursor = cursor def fetchone(self): return self.cursor.fetchone() def fetchall(self): return self.cursor.fetchall() def __i
class _Sqlite3Cursor(object):
def __init__(self, cursor):
self.cursor = cursor
def fetchone(self):
return self.cursor.fetchone()
def fetchall(self):
return self.cursor.fetchall()
def __iter__(self):
return self
def next(self):
return self.cursor.next()
fetchone和fetchall似乎返回它们自己而不做任何其他事情,这个类有用吗?它可能只是作为占位符存在。如果其他数据库后端(例如MySQL)需要特殊处理,那么即使Sqlite不做任何事情,也可以为它提供一个处理,因此如果以后确实需要为Sqlite做一些特殊的事情,您可以进行更改。