Menu

Datetime problems

2005-04-18
2012-09-19
  • Dagur Páll Ammendrup

    I have two datetime objects, one from the database and one which I created with the datetime module. When I compare them it works fine on Windows but when I try it on my Fedora 3 I get this error:

    exceptions.TypeError: can't compare datetime.datetime to DateTime

    This must be a bug, but who's responsible for it?

     
    • Andy Dustman

      Andy Dustman - 2005-04-18

      What versions of everything are you using? (Python, MySQL, MySQL-python)

      It looks like you have mx.DateTime on your Fedora Core system.MySQLdb uses the Python datetime types (available in Python-2.3 and newer) when it finds them.

      It would be possible to reconfigure MySQLdb to not use datetime, I suppose, or you could change your application to not use mx.DateTime.

       
      • Dagur Páll Ammendrup

        Python 2.3.4
        MySQL 3.23.58
        MySQL-python 0.9.2

        I guess I will just use mx.DateTime. Will it change anything if I upgraed to MySQL-python 1.2? I was trying it earlier but I ran into this problem: (http://sourceforge.net/forum/forum.php?thread_id=1268634&forum_id=70461)

        btw, sorry for posting in the wrong forum.

         
        • Andy Dustman

          Andy Dustman - 2005-04-19

          No, it should still try to use the Python datetime objects first, in both 1.0 and 1.2, You may want to take a look at MySQLdb/*times.py and MySQLdb/converters.py to see how it picks the right type of datetime object, particularly times.py. If you change the import order, it should do what you want. I try to use native Python types whenever possible.

           

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.