Setup:
I have created and populated a sqllite database in Pycharm, running Python + Flask + SQLAlchemy.
The code works perfectly in the console, but when i run it, i get a:
OperationalError: (sqlite3.OperationalError) unable to open database file
Problem:
When i run print os.getcwd() in Chrome/Flask-Werkzeug:
C:\Program Files (x86)\JetBrains\PyCharm 4.0.6\jre\jre\bin.
that is the wrong folder. The whole project, including the .db is in C:\Users\Finn\PycharmProjects. Why is that and what do i do about it?
Code:
Base = declarative_base()
engine = create_engine("sqlite:///temp/database.db")
DBSession = sessionmaker(bind=engine)
session = DBSession()
**more Imports, DB-Setup & Classes**
class DBHandl():
@classmethod
def getData(self): # Return Personen + Adressen
q = session.query(Person, Address).filter(Person.id == Address.person_id).all()
return q
@app.route('/')
def hello_world():
q = DBHandl.getData()
return render_template("home.html", list=q)
Aucun commentaire:
Enregistrer un commentaire