Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"no such table" with sqlite3 #853

Closed
andreas00 opened this issue Sep 2, 2013 · 2 comments
Closed

"no such table" with sqlite3 #853

andreas00 opened this issue Sep 2, 2013 · 2 comments

Comments

@andreas00
Copy link

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?

@ghost
Copy link

ghost commented Sep 3, 2013

Maybe you're using two different databases... Use absolute paths!

@DasIch
Copy link
Contributor

DasIch commented Sep 3, 2013

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.

@DasIch DasIch closed this as completed Sep 3, 2013
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants