1

So I've created a database called "school" which appears in the ArangoDB web UI. However after running my app.py file I receive the following trace error in the command prompt which prevents the python server from booting up.

Note: I'm running Python 3.7.3 and Flask 1.0.2 with the python driver pyArango-1.3.2 to connect to ArangoDB version 3.4.6-1

Here's the rather simple code I'm using...

from flask import Flask, session, render_template, redirect, flash, url_for, send_from_directory, request
from flask_cors import CORS
from werkzeug.utils import secure_filename
from pyArango.connection import *

conn = Connection(username="root", password="password")

conn.createDatabase(name="school")

db = conn["school"]

Any idea what might be causing the error below?:

  File "C:\Users\username\newproject_v2\newprojectv2\app.py", line 9, in <module>
    conn.createDatabase(name="school")
  File "C:\Users\username\Envs\newprojectv2\lib\site-packages\pyArango\connection.py", line 163, in createDatabase
    raise CreationError(data["errorMessage"], r.content)
pyArango.theExceptions.CreationError: duplicate name. Errors: b'{"error":true,"errorMessage":"duplicate name","code":409,"errorNum":1207}'

1 Answer 1

1

I think you can create a database only once. Check if the connection already has a db with the same name. If it doesn't exists then create one. hasDatabase can help you there.

from flask import Flask, session, render_template, redirect, flash, url_for, send_from_directory, request
from flask_cors import CORS
from werkzeug.utils import secure_filename
from pyArango.connection import *

conn = Connection(username="root", password="password")
if not conn.hasDatabase("school"):
    conn.createDatabase(name="school")

db = conn["school"]
Sign up to request clarification or add additional context in comments.

1 Comment

This works great, got an indentation error at first, then realised I forgot to add a tab before the conn.CreateDatabase line. Thanks @Madhan Varadhodiyil

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.