fix conversion of datetime microseconds

Issue #605 resolved
Former user created an issue

some values get returned as 5e-05. May only happen with psycopg1

Index: lib/sqlalchemy/databases/postgres.py
===================================================================
--- lib/sqlalchemy/databases/postgres.py        (revision 2727)
+++ lib/sqlalchemy/databases/postgres.py        (working copy)
@@ -70,7 +70,7 @@
             return None
         second_parts = str(value.second).split(".")
         seconds = int(second_parts[0](0))
-        microseconds = int(second_parts[1](1))
+        microseconds = int(float(second_parts[1](1)))
         return datetime.datetime(value.year, value.month, value.day,
                                  value.hour, value.minute, seconds,
                                  microseconds)

Comments (3)

  1. Log in to comment