Skip to content

Commit

Permalink
add fetch_next_row method that simply returns a tuple and change canc…
Browse files Browse the repository at this point in the history
…el to a cpdef method
  • Loading branch information
damoxc committed Mar 3, 2010
1 parent 2c2dce0 commit 5d13df0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
5 changes: 5 additions & 0 deletions _mssql.pxd
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from sqlfront cimport DBPROCESS, BYTE


cdef void log(char *, ...)

cdef struct _mssql_parameter_node:
_mssql_parameter_node *next
BYTE *value
Expand All @@ -23,9 +26,11 @@ cdef class MSSQLConnection:
cdef tuple column_names
cdef tuple column_types

cpdef cancel(self)
cdef void clear_metadata(self)
cdef convert_db_value(self, BYTE *, int, int)
cdef BYTE *convert_python_value(self, value, int*, int*)
cdef fetch_next_row(self, int)
cdef fetch_next_row_dict(self, int)
cdef format_and_run_query(self, query_string, params=?)
cdef format_sql_command(self, format, params=?)
Expand Down
21 changes: 13 additions & 8 deletions _mssql.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ min_error_severity = 6
# Buffer size for large numbers
DEF NUMERIC_BUF_SZ = 45

cdef void log(char * message):
cdef void log(char * message, ...):
if PYMSSQL_DEBUG != 1:
return
fprintf(stderr, "+++ %s\n", message)
Expand Down Expand Up @@ -414,7 +414,7 @@ cdef class MSSQLConnection:
clr_err(self)
return MSSQLRowIterator(self)

def cancel(self):
cpdef cancel(self):
"""
cancel() -- cancel all pending results.
Expand Down Expand Up @@ -736,11 +736,10 @@ cdef class MSSQLConnection:
return None

return self.get_row(rtc)[0]
cdef fetch_next_row_dict(self, int throw):

cdef fetch_next_row(self, int throw):
cdef RETCODE rtc
cdef int col
log("_mssql.MSSQLConnection.fetch_next_row_dict()")
log("_mssql.MSSQLConnection.fetch_next_row()")

self.get_result()

Expand All @@ -762,9 +761,15 @@ cdef class MSSQLConnection:
if throw:
raise StopIteration
return None


return self.get_row(rtc)

cdef fetch_next_row_dict(self, int throw):
cdef int col
log("_mssql.MSSQLConnection.fetch_next_row_dict()")

row_dict = {}
row = self.get_row(rtc)
row = self.fetch_next_row(throw)

for col in xrange(1, self.num_columns + 1):
name = self.column_names[col - 1]
Expand Down

0 comments on commit 5d13df0

Please sign in to comment.