Skip to content

Commit

Permalink
MongoDB: Improve reading timestamps in previous BSON formats
Browse files Browse the repository at this point in the history
bson.errors.InvalidBSON: year 292278994 is out of range

Consider Using CodecOptions(datetime_conversion=DATETIME_AUTO) or MongoClient(datetime_conversion='DATETIME_AUTO').

See: https://pymongo.readthedocs.io/en/stable/examples/datetimes.html#handling-out-of-range-datetimes
  • Loading branch information
amotl committed Sep 2, 2024
1 parent bf78869 commit 71e3aa7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
## Unreleased
- MongoDB: Rename columns with leading underscores to use double leading underscores
- MongoDB: Add support for UUID types
- MongoDB: Improve reading timestamps in previous BSON formats

## 2024/09/02 v0.0.21
- DynamoDB: Add special decoding for varied lists.
Expand Down
2 changes: 1 addition & 1 deletion cratedb_toolkit/io/mongodb/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def gather_collections(database) -> t.List[str]:

def get_mongodb_client_database(args, **kwargs) -> t.Tuple[pymongo.MongoClient, pymongo.database.Database]:
client: pymongo.MongoClient
client = pymongo.MongoClient(args.url, **kwargs)
client = pymongo.MongoClient(args.url, datetime_conversion="DATETIME_AUTO", **kwargs)
db: pymongo.database.Database = client.get_database(args.database)
return client, db

Expand Down

0 comments on commit 71e3aa7

Please sign in to comment.