Changeset 810

Show
Ignore:
Timestamp:
03/08/07 17:27:03 (2 years ago)
Author:
mfenniak
Message:

Add final support for bin/txt types together by using DescribePreparedStatement?

Files:

Legend:

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

    r809 r810  
    635635            while 1: 
    636636                msg = self._read_message() 
    637                 print repr(msg) 
    638637                if isinstance(msg, Protocol.ParseComplete): 
    639638                    # ok, good. 
     
    671670            # get back from this statement.  Now we can Bind values. 
    672671            output_fc = [Types.py_type_info(f) for f in row_desc.fields] 
    673             print repr(output_fc) 
    674672            self._send(Protocol.Bind(portal, statement, param_fc, params, output_fc, self._client_encoding)) 
    675             print "bind" 
     673            # I don't know why we need to send DescribePortal again, but without it, 
     674            # we don't receive our BindComplete.  It's like Flush fails to work. 
     675            self._send(Protocol.DescribePortal(portal)) 
    676676            self._send(Protocol.Flush()) 
    677             print "flush" 
    678677            while 1: 
    679678                msg = self._read_message() 
    680                 print repr(msg) 
    681679                if isinstance(msg, Protocol.BindComplete): 
    682680                    # good news everybody! 
    683                     #return row_desc 
    684681                    pass 
     682                elif isinstance(msg, Protocol.RowDescription): 
     683                    # Return the new row desc, since it will have the format 
     684                    # types we asked for 
     685                    return msg 
    685686                elif isinstance(msg, Protocol.ErrorResponse): 
    686687                    raise msg.createException() 
  • pg8000/trunk/pg8000-test.py

    r809 r810  
    66import pg8000 
    77 
    8 db = pg8000.Connection(host='joy.fenniak.net', user='Mathieu Fenniak', database="software", password="hello", socket_timeout=5) 
     8#db = pg8000.Connection(host='joy.fenniak.net', user='Mathieu Fenniak', database="software", password="hello", socket_timeout=5) 
     9db = pg8000.Connection(host='localhost', user='mfenniak') 
    910db.iterate_dicts = True 
    1011 
     
    3233print "Beginning type checks..." 
    3334 
     35cur1.execute("SELECT $1", 5) 
     36assert tuple(cur1) == ({"?column?": 5},) 
     37 
    3438cur1.execute("SELECT 5000::smallint") 
    3539assert tuple(cur1) == ({"int2": 5000},) 
     
    4549 
    4650cur1.execute("SELECT 1.1::real") 
    47 assert tuple(cur1) == ({"float4": 1.1000000000000001},) 
     51assert tuple(cur1) == ({"float4": 1.1000000238418579},) 
    4852 
    4953cur1.execute("SELECT 1.1::double precision")