Skip to content

Commit

Permalink
Changed pandas timestamp to python datetime && deleted pandas dependecy
Browse files Browse the repository at this point in the history
  • Loading branch information
Aymaru authored and amotl committed Jul 18, 2022
1 parent f476ede commit f2b15eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

requirements = [
'urllib3>=1.9',
"pandas>=1.2.2, <1.3",
]


Expand Down
9 changes: 6 additions & 3 deletions src/crate/client/cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from .exceptions import ProgrammingError
import warnings
import pandas as pd
from datetime import datetime


class Cursor(object):
Expand Down Expand Up @@ -72,15 +72,18 @@ def _transform_date_columns(row, gen_flags):
Generates iterates over each value from a row and converts timestamps to pandas TIMESTAMP
"""
for value in row:
flag = next(gen_flags)
try:
flag = next(gen_flags)
except StopIteration:
break

if not flag or value is None:
yield value
else:
if value < 0:
yield None
else:
value = pd.Timestamp(float(str(value)[0:13]), unit='ms')
value = datetime.fromtimestamp(value/1000)
yield value

def executemany(self, sql, seq_of_parameters):
Expand Down

0 comments on commit f2b15eb

Please sign in to comment.