Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
website_project/make_db.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
26 lines (19 sloc)
640 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
from flask import render_template | |
import sqlite3 | |
app = Flask(__name__) | |
@app.route('/books') | |
def books(): | |
con = sqlite3.connect('database.db') | |
try: | |
con.execute('CREATE TABLE books (isbn PRIMARY KEY INT,name TEXT, price INT, date TEXT, trade_price REAL, image TEXT )') | |
print ('Table created successfully'); | |
except: | |
pass | |
con.close() | |
con = sqlite3.connect("database.db") | |
con.row_factory = sqlite3.Row | |
cur = con.cursor() | |
cur.execute("SELECT * from books") | |
rows = cur.fetchall(); | |
return render_template("books.html", rows = rows) |