mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-26 10:53:44 +03:00
Added name parameters to .cursor() calls in extras.
This commit is contained in:
parent
dfda372fae
commit
0422506404
|
@ -1,3 +1,7 @@
|
||||||
|
2007-09-01 Federico Di Gregorio <fog@initd.org>
|
||||||
|
|
||||||
|
* Added "name" parameter to all .cursor() calls in extras.py.
|
||||||
|
|
||||||
2007-05-29 Federico Di Gregorio <fog@initd.org>
|
2007-05-29 Federico Di Gregorio <fog@initd.org>
|
||||||
|
|
||||||
* Release 2.0.6.
|
* Release 2.0.6.
|
||||||
|
|
|
@ -69,8 +69,11 @@ class DictCursorBase(_cursor):
|
||||||
|
|
||||||
class DictConnection(_connection):
|
class DictConnection(_connection):
|
||||||
"""A connection that uses DictCursor automatically."""
|
"""A connection that uses DictCursor automatically."""
|
||||||
def cursor(self):
|
def cursor(self, name=None):
|
||||||
return _connection.cursor(self, cursor_factory=DictCursor)
|
if name is None:
|
||||||
|
return _connection.cursor(self, cursor_factory=DictCursor)
|
||||||
|
else:
|
||||||
|
return _connection.cursor(self, name, cursor_factory=DictCursor)
|
||||||
|
|
||||||
class DictCursor(DictCursorBase):
|
class DictCursor(DictCursorBase):
|
||||||
"""A cursor that keeps a list of column name -> index mappings."""
|
"""A cursor that keeps a list of column name -> index mappings."""
|
||||||
|
@ -135,8 +138,11 @@ class DictRow(list):
|
||||||
|
|
||||||
class RealDictConnection(_connection):
|
class RealDictConnection(_connection):
|
||||||
"""A connection that uses RealDictCursor automatically."""
|
"""A connection that uses RealDictCursor automatically."""
|
||||||
def cursor(self):
|
def cursor(self, name=None):
|
||||||
return _connection.cursor(self, cursor_factory=RealDictCursor)
|
if name is None:
|
||||||
|
return _connection.cursor(self, cursor_factory=RealDictCursor)
|
||||||
|
else:
|
||||||
|
return _connection.cursor(self, name, cursor_factory=RealDictCursor)
|
||||||
|
|
||||||
class RealDictCursor(DictCursorBase):
|
class RealDictCursor(DictCursorBase):
|
||||||
"""A cursor that uses a real dict as the base type for rows.
|
"""A cursor that uses a real dict as the base type for rows.
|
||||||
|
@ -215,9 +221,12 @@ class LoggingConnection(_connection):
|
||||||
raise self.ProgrammingError(
|
raise self.ProgrammingError(
|
||||||
"LoggingConnection object has not been initialize()d")
|
"LoggingConnection object has not been initialize()d")
|
||||||
|
|
||||||
def cursor(self):
|
def cursor(self, name=None):
|
||||||
self._check()
|
self._check()
|
||||||
return _connection.cursor(self, cursor_factory=LoggingCursor)
|
if name is None:
|
||||||
|
return _connection.cursor(self, cursor_factory=LoggingCursor)
|
||||||
|
else:
|
||||||
|
return _connection.cursor(self, name, cursor_factory=LoggingCursor)
|
||||||
|
|
||||||
class LoggingCursor(_cursor):
|
class LoggingCursor(_cursor):
|
||||||
"""A cursor that logs queries using its connection logging facilities."""
|
"""A cursor that logs queries using its connection logging facilities."""
|
||||||
|
@ -254,9 +263,12 @@ class MinTimeLoggingConnection(LoggingConnection):
|
||||||
if t > self._mintime:
|
if t > self._mintime:
|
||||||
return msg + os.linesep + " (execution time: %d ms)" % t
|
return msg + os.linesep + " (execution time: %d ms)" % t
|
||||||
|
|
||||||
def cursor(self):
|
def cursor(self, name=None):
|
||||||
self._check()
|
self._check()
|
||||||
return _connection.cursor(self, cursor_factory=MinTimeLoggingCursor)
|
if name is None:
|
||||||
|
return _connection.cursor(self, cursor_factory=MinTimeLoggingCursor)
|
||||||
|
else:
|
||||||
|
return _connection.cursor(self, name, cursor_factory=MinTimeLoggingCursor)
|
||||||
|
|
||||||
class MinTimeLoggingCursor(LoggingCursor):
|
class MinTimeLoggingCursor(LoggingCursor):
|
||||||
"""The cursor sub-class companion to MinTimeLoggingConnection."""
|
"""The cursor sub-class companion to MinTimeLoggingConnection."""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user