ArangoDB-Community / pyArango

Python Driver for ArangoDB with built-in validation
https://pyarango.readthedocs.io/en/latest/
Apache License 2.0
238 stars 90 forks source link

pyArango.collection.Collection delete() not working in python Run mode but it works in debug mode using PyCharm #195

Open al20139471 opened 3 years ago

al20139471 commented 3 years ago

I encountered a weird issue with pyArango.collection.Collection delete() function

First I need to check if the collection exists in the database. Then if it exists, delete it. And finally create the collection. This following piece of code runs fine in Debug mode using PyCharm, meaning it deletes the collection from my localhost arangodb in MacOS. But when I run the code in terminal using python main.py it yields this error. The same error when I run main.py in PyCharm: pyArango.theExceptions.CreationError: Database _system already has a collection named nodes_2020_09_21_FY20Q4. Errors: {} Can you check and let me know what's the issue? Here is main.py (the Connection arguments and node_nm are populated in actual file)

from pyArango.connection import Connection
conn = Connection(arangoURL=arango_host, username=user, password=password)
db = conn["_system"]
if db.hasCollection(node_nm):
     db[node_nm].delete()

node = db.createCollection(name=node_nm)