Python- CreateCollectioin

Hello Everybody,
how can i write this code:
db.createCollection(“weather”, { timeseries: { timeField: “timestamp” } } )
in Python/Pymongo
db.create_collection( ??? )

@Braustuble_trinker That example is mongosh format.

For python you will need something like:

conn = pymongo.MongoClient('mongodb://localhost')
# create timeseries collection weather in db test
conn.test.create_collection('weather',timeseries={'timeField':'timestamp'})
1 Like

@Braustuble_trinker, you can also use the following - issue a database command, for example:

db.command("create", 'py_collection', timeseries={ 'timeField': 'timestamp', 'metaField': 'data', 'granularity': 'hours' })