You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Whenever I try to set the Python driver as it's shown below. I follow the instructions that are shown in this link from the Python course. So it is pretty much like:
importosfromflaskimportFlask, current_appfromneo4jimportGraphDatabaseNEO4J_URI=os.getenv('NEO4J_URI')
NEO4J_USERNAME=os.getenv('NEO4J_USERNAME')
NEO4J_PASSWORD=os.getenv('NEO4J_PASSWORD')
"""Initiate the Neo4j Driver"""definit_driver(uri, username, password):
# Create an instance of the drivercurrent_app.driver=GraphDatabase.driver(uri, auth=(username, password))
# Verify Connectivitycurrent_app.driver.verify_connectivity()
returncurrent_app.driver
And this is the error when I testi it or execute it:
(venv) kivanc57@linuxmint:~/Desktop/neo4j_api$ pytest tests/01_connect_to_neo4j__test.py
ImportError while loading conftest '/home/kivanc57/Desktop/neo4j_api/tests/conftest.py'.
tests/conftest.py:7: in<module>
from api import create_app
api/__init__.py:16: in<module>
from .neo4j import init_driver
api/neo4j.py:44: in<module>
init_driver(NEO4J_URI, NEO4J_USERNAME, NEO4J_PASSWORD)
api/neo4j.py:15: in init_driver
current_app.driver = GraphDatabase.driver(uri, auth=(username, password))
venv/lib/python3.12/site-packages/werkzeug/local.py:316: in __get__
obj = instance._get_current_object() # type: ignore[misc]
venv/lib/python3.12/site-packages/werkzeug/local.py:513: in _get_current_object
raise RuntimeError(unbound_message) from None
E RuntimeError: Working outside of application context.
E
E This typically means that you attempted to use functionality that needed
E the current application. To solve this, set up an application context
E with app.app_context(). See the documentation for more information.
I know that it is because of wrong applications of Flask but then the course's code is problematic if I really have to change the Flask code whereas it should stay constant so I do not want to change it.
The text was updated successfully, but these errors were encountered:
Whenever I try to set the Python driver as it's shown below. I follow the instructions that are shown in this link from the Python course. So it is pretty much like:
And this is the error when I testi it or execute it:
I know that it is because of wrong applications of Flask but then the course's code is problematic if I really have to change the Flask code whereas it should stay constant so I do not want to change it.
The text was updated successfully, but these errors were encountered: