Changeset 845

Show
Ignore:
Timestamp:
03/13/07 12:31:49 (2 years ago)
Author:
mfenniak
Message:

Add datetime type upload.

Files:

Legend:

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

    r842 r845  
    14971497        return datetime.datetime(year, month, day, hour, minute, int(sec), int((sec - int(sec)) * 1000000)) 
    14981498 
     1499    def timestamp_out(v, **kwargs): 
     1500        return v.isoformat(' ') 
     1501 
    14991502    def numeric_in(data, **kwargs): 
    15001503        if data.find(".") == -1: 
     
    15571560        decimal.Decimal: {"tid": 1700, "txt_out": numeric_out}, 
    15581561        Bytea: {"tid": 17, "bin_out": byteasend}, 
     1562        datetime.datetime: {"tid": 1114, "txt_out": timestamp_out}, 
    15591563        type(None): {"tid": -1}, 
    15601564    } 
  • pg8000/trunk/pg8000_test.py

    r843 r845  
    330330                "retrieved value match failed") 
    331331 
     332    def TestTimestampRoundtrip(self): 
     333        v = datetime.datetime(2001, 2, 3, 4, 5, 6, 170000) 
     334        db.execute("SELECT $1 as f1", v) 
     335        retval = tuple(db.iterate_dict()) 
     336        self.assert_(retval == ({"f1": v},), 
     337                "retrieved value match failed") 
     338 
    332339    def TestOidIn(self): 
    333340        db.execute("SELECT oid FROM pg_type")