Spaces:
Runtime error
Runtime error
Download db.py from HuanzhiMao/dual_window: direct link, hf CLI and curl.
- Browser
- Download file 373 Bytes
-
https://huggingface.co/spaces/HuanzhiMao/dual_window/resolve/ea4ea4b0c0c7ff5a2e318e616e2f111dec7d2e01/db.py
- Command line
-
hf download hf://spaces/HuanzhiMao/dual_window@ea4ea4b0c0c7ff5a2e318e616e2f111dec7d2e01/db.py
-
curl -L -o db.py https://huggingface.co/spaces/HuanzhiMao/dual_window/resolve/ea4ea4b0c0c7ff5a2e318e616e2f111dec7d2e01/db.py
373 Bytes
| from pymongo import MongoClient | |
| from pymongo.server_api import ServerApi | |
| import os | |
| uri = os.getenv('DATABASE_URL').strip() | |
| cluster = MongoClient(uri, server_api=ServerApi('1')) | |
| try: | |
| cluster.admin.command('ping') | |
| print("Pinged your deployment. You successfully connected to MongoDB!") | |
| except Exception as e: | |
| print(e) | |
| db = cluster["test"] | |
| collection = db["test"] |