Fix bug di mysql vecchissimo

master
Pietro Brenna 2020-08-05 09:10:31 +02:00
parent cd2fd4c6c0
commit 56e7c7b578
1 changed files with 10 additions and 2 deletions

View File

@ -617,10 +617,18 @@ def _unknownSqlTypeConverter(rs, col):
return rs.getObject(col) return rs.getObject(col)
def _to_datetime(rs, col): def _to_datetime(rs, col):
import jpype
SQLException = jpype.java.sql.SQLException
try:
java_val = rs.getTimestamp(col) java_val = rs.getTimestamp(col)
except:
java_val = bytes(rs.getBytes(col)).decode('utf-8')
if not java_val: if not java_val:
return return
try:
d = datetime.datetime.strptime(str(java_val)[:19], "%Y-%m-%d %H:%M:%S") d = datetime.datetime.strptime(str(java_val)[:19], "%Y-%m-%d %H:%M:%S")
except ValueError:
return ""
d = d.replace(microsecond=int(str(java_val.getNanos())[:6])) d = d.replace(microsecond=int(str(java_val.getNanos())[:6]))
return str(d) return str(d)