Re: timestamp without time zone in version2.5.1

Andrew McNamara <[email protected]> Mon, 26 Jun 2006 14:02:45 +1000
Newsgroups gmane.comp.python.db.pypgsql.user
Message-ID <[email protected]>
This is a multipart MIME message.

--==_Exmh_1151294550_27010
Content-Type: text/plain; charset=us-ascii

>> For some reason, when I tried to read timestamp without time zone data,
>> it is processed as a GMC time + local time zone instead of a local 
time.
>
>Thanks for the report (you're the third one). I'll try to release a fixed
>version the next few days.

I started creating some "acceptance tests" for new versions of pyPgSQL to
be used with our application (www.netepi.org). I didn't get very far - the
inconsistencies with the date/time types confounded me utterly (by the way,
psycopg is even worse in this respect). My focus was to get back the same
value on select as I inserted into a table.

You might be interested in adding an elaborated version of the attached to
the pyPgSQL unit tests (once they pass!).

-- 
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/


--==_Exmh_1151294550_27010
Content-Type: text/x-python ; name="mytests.py"; charset=us-ascii
Content-Description: mytests.py
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="mytests.py"

import unittest
from mx import DateTime
from pyPgSQL import PgSQL
#PgSQL.useUTCtimeValue =3D True

#import psycopg as PgSQL

db =3D PgSQL.connect(database=3D'test')

class DateTest(unittest.TestCase):
    def _test(self, sql_type, value):
        curs =3D db.cursor()
        try:
            curs.execute('create table mytests (col %s)' % sql_type)
            curs.execute('insert into mytests values (%s)', (value,))
            curs.execute('select * from mytests')
            pgval, =3D curs.fetchone()
            pgtype =3D 'unknown'
            v =3D curs.description[0][1].value
            # This is a bit of a hack... find the Pg symbol...
            for name, obj in vars(PgSQL).items():
                try:
                    if v =3D=3D int(obj):
                        pgtype =3D name
                        break
                except (ValueError, TypeError, AttributeError):
                    pass
            else:
                pgtype =3D repr(v)
#            print '%r %r %r %s %s' % (value, pgval, sql_type, type(pgval=
), pgtype)
            self.assertEqual(value, pgval, =

                             '%r !=3D %r (sql %r, py %s, pgtype %s)' %\
                             (value, pgval, sql_type, type(pgval), pgtype=
))
        finally:
            curs.close()
            db.rollback()

    def test_timestamp(self):
        self._test('timestamp', DateTime.DateTime(1999,3,4,5,6,7))

    def test_timestamp_with_time_zone(self):
        self._test('timestamp with time zone', =

                   DateTime.DateTime(1999,3,4,5,6,7))

    def test_timestamp_without_time_zone(self):
        self._test('timestamp without time zone', =

                   DateTime.DateTime(1999,3,4,5,6,7))

    def test_time(self):
        self._test('time', DateTime.Time(5,6,7))

    def test_time_with_time_zone(self):
        self._test('time with time zone', DateTime.Time(5,6,7))

    def test_time_without_time_zone(self):
        self._test('time without time zone', DateTime.Time(5,6,7))


if __name__ =3D=3D '__main__':
    unittest.main()
--==_Exmh_1151294550_27010
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
--==_Exmh_1151294550_27010
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Pypgsql-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pypgsql-users

--==_Exmh_1151294550_27010--