Giter Club home page Giter Club logo

flask_vote_app's Issues

Operational Error

The error message is

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) unable to open database file

(Background on this error at: https://sqlalche.me/e/14/e3q8)

It says the error is on line
fighters = Fighter.query.order_by('id').all()

My Run.py File is configured like this
`import os
from flask import Flask, render_template
from flask_sqlalchemy import SQLAlchemy

app = Flask(name)

DATABASE_URL is by default

app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///tmp/test.db'
db = SQLAlchemy(app)

#app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get'DATABASE_URL', 'sqlite:///tmp/test.db'

class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
email = db.Column(db.String(120), unique=True)

def __init__(self, email):
    self.email = email

def __repr__(self):
    return '<User %r>' % self.email

class Fighter(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(120), unique=True)

class Vote(db.Model):
id = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
user = db.relationship('User', backref=db.backref('votes', lazy='dynamic'))
fighter_id = db.Column(db.Integer, db.ForeignKey('fighter.id'))
fighter = db.relationship('Fighter', backref=db.backref('votes', lazy='dynamic'))

@app.route('/', methods=['GET', 'POST'])
def homepage():
fighters = Fighter.query.all()
return render_template('index.html', fighters=fighters)

if name == 'main':
app.run(debug=True)`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.