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
Hi,
I've write a simple code for open a sqlite db with flask.
from flask import Flask, render_template, g
import sqlite3 as lite
# configuration
DATABASE = 'card.db'
DEBUG = True
app = Flask(__name__)
app.config.from_object(__name__)
@app.route('/')
def index():
g.db = lite.connect(app.config['DATABASE'])
cur = g.db.execute('select * from card')
cards = [dict(card_name=row[1], low=row[2], medium=row[3], high=row[4]) for row in cur.fetchall()]
g.db.close()
render_template('index.html', cards=cards)
if __name__ == '__main__':
app.run()
but when i launch the app:
OperationalError: no such table: card
'card.db' is in the main folder with the script and when i open the db with the python console work perfectly
>>> import sqlite3 as lite
>>> conn = lite.connect('card.db')
>>> cur = conn.execute('select * from card')
>>> rows = cur.fetchall()
>>> for row in rows:
... print row
I've try to change path but:
OperationalError: unable to open database file
or remove the quotes from app.config['DATABASE'] but:
KeyError: 'card.db'
I've tried with another project from 0, another db, other information but flask give me the same error
OperationalError: no such table: film
How i can resolve?
The text was updated successfully, but these errors were encountered:
You shouldn't use relative paths in WSGI applications. Apart from that please use a proper support channel like the IRC channel or the mailinglist. The community page provides information on how you can access them.
Hi,
I've write a simple code for open a sqlite db with flask.
but when i launch the app:
'card.db' is in the main folder with the script and when i open the db with the python console work perfectly
I've try to change path but:
or remove the quotes from app.config['DATABASE'] but:
I've tried with another project from 0, another db, other information but flask give me the same error
How i can resolve?
The text was updated successfully, but these errors were encountered: