Changeset 801

Show
Ignore:
Timestamp:
03/07/07 21:21:59 (2 years ago)
Author:
mfenniak
Message:

work on supporting numeric types

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • pg8000/trunk/pg8000.py

    r800 r801  
    593593            self.verifyState("ready") 
    594594            self._send(Protocol.Parse(statement, qs, [type(x) for x in params])) 
    595             self._send(Protocol.Bind(portal, statement, (1,), params, (1,))) 
     595            self._send(Protocol.Bind(portal, statement, (0,), params, (0,))) 
    596596            self._send(Protocol.DescribePortal(portal)) 
    597597            self._send(Protocol.Flush()) 
     
    741741        return int(data) 
    742742 
     743    def int4out(v): 
     744        return str(v) 
     745 
    743746    def int4send(v): 
    744747        return struct.pack("!i", v) 
     
    757760        return datetime.datetime(year, month, day, hour, minute, sec) 
    758761 
     762    def numeric_in(data, description): 
     763        if data.find(".") == -1: 
     764            return int(data) 
     765        else: 
     766            return decimal(data) 
     767 
     768    def numeric_out(v): 
     769        return str(v) 
     770 
    759771    py_types = { 
    760         int: (23, None, int4send), 
     772        int: (1700, numeric_out, None), 
    761773    } 
    762774 
     
    766778        23: (int4in, int4recv), 
    767779        1114: (timestamp_in, timestamp_recv), 
     780        1700: (numeric_in, None), 
    768781    } 
    769782 
  • pg8000/trunk/pg8000-test.py

    r800 r801  
    2828 
    2929print "begin query..." 
    30 cur1.execute("SELECT 5000 + 1 as int_test, True as bool_test, '2000-01-02 03:04:05.67'::timestamp as timestamp_test") 
     30cur1.execute("SELECT 5000 + 1 as int_test, True as bool_test, '2000-01-02 03:04:05.67'::timestamp as timestamp_test, 22::numeric") 
    3131for row in cur1: 
    3232    print repr(row)