Changeset 824
- Timestamp:
- 03/09/07 22:20:23 (1 year ago)
- Files:
-
- pg8000/trunk/pg8000.py (modified) (4 diffs)
- pg8000/trunk/pg8000-test.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
pg8000/trunk/pg8000.py
r823 r824 765 765 766 766 def _send(self, msg): 767 #print repr(msg)768 767 data = msg.serialize() 769 768 self._sock.send(data) … … 1087 1086 1088 1087 def py_value(v, description, **kwargs): 1089 print repr(v), repr(description)1090 1088 if v == None: 1091 1089 # special case - NULL value … … 1143 1141 return float(data) 1144 1142 1145 def timestamp_recv(data, **kwargs): 1146 val = struct.unpack("!d", data)[0] 1147 print "timestamp_recv", repr(val), repr(data) 1148 return datetime.datetime(2000, 1, 1) + datetime.timedelta(seconds = val) 1143 # The timestamp_recv function is sadly not in use because some PostgreSQL 1144 # servers are compiled with HAVE_INT64_TIMESTAMP, and some are not. This 1145 # alters the binary format of the timestamp, cannot be perfectly detected, 1146 # and there is no message from the server indicating which format is in 1147 # use. Ah, well, obviously binary formats are hit-and-miss... 1148 #def timestamp_recv(data, **kwargs): 1149 # val = struct.unpack("!d", data)[0] 1150 # return datetime.datetime(2000, 1, 1) + datetime.timedelta(seconds = val) 1149 1151 1150 1152 def timestamp_in(data, **kwargs): … … 1224 1226 1042: {"txt_in": varcharin}, # CHAR type 1225 1227 1043: {"txt_in": varcharin}, # VARCHAR type 1226 1114: {"txt_in": timestamp_in , "bin_in": timestamp_recv, "prefer": "bin"},1228 1114: {"txt_in": timestamp_in}, #, "bin_in": timestamp_recv, "prefer": "bin"}, 1227 1229 1186: {"txt_in": interval_in}, 1228 1230 1700: {"txt_in": numeric_in}, pg8000/trunk/pg8000-test.py
r823 r824 113 113 cur1.execute("SELECT '2001-02-03 04:05:06.17'::timestamp") 114 114 retval = tuple(cur1.iterate_dict()) 115 print repr(retval)116 115 assert retval == ({'timestamp': datetime.datetime(2001, 2, 3, 4, 5, 6, 170000)},) 117 116
