BuzzCutNorman / tap-mssql

Singer Tap for MS SQL built with Meltano Singer SDK.
MIT License
2 stars 9 forks source link

fix: Extended JSONEncoder to deal with datetime #4

Closed BuzzCutNorman closed 2 years ago

BuzzCutNorman commented 2 years ago

Fixes #2

I copied get_batches from singer_sdk/streams/core.py into the mssqlStream class. To stop pylance from barking about the new union style not allowed I copied and added from __future__ import annotations from core.py to the client.py file. I followed this article https://dev.to/kfuquay/extending-pythons-json-encoder-7k0that which has a nice write up on how to extended the JSONEncoder class. The only change needed was to use the pendulum line from the sdk _typing.py to format the datetime string obj = pendulum.instance(obj).isoformat()
Here is the line with the extended encoder in place (json.dumps(record, cls=CustomJSONEncoder) + "\n").encode() for record in chunk