aboutsummaryrefslogtreecommitdiff
path: root/ustayml/views/blog.py
diff options
context:
space:
mode:
Diffstat (limited to 'ustayml/views/blog.py')
-rw-r--r--ustayml/views/blog.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/ustayml/views/blog.py b/ustayml/views/blog.py
index 57ba4ba..165d358 100644
--- a/ustayml/views/blog.py
+++ b/ustayml/views/blog.py
@@ -15,7 +15,7 @@ def index():
db = get_db()
posts = db.execute(
'SELECT p.id, title, body, created, author_id, username'
- ' FROM post p JOIN user u ON p.author_id = u.id'
+ ' FROM post p JOIN \"user\" u ON p.author_id = u.id'
' ORDER BY created DESC'
).fetchall()
return render_template('blog/index.html', posts=posts)
@@ -38,7 +38,7 @@ def create():
db = get_db()
db.execute(
'INSERT INTO post (title, body, author_id)'
- ' VALUES (?, ?, ?)',
+ ' VALUES (%s, %s, %s)',
(title, body, g.user['id'])
)
db.commit()
@@ -65,8 +65,8 @@ def update(id):
else:
db = get_db()
db.execute(
- 'UPDATE post SET title = ?, body = ?'
- ' WHERE id = ?',
+ 'UPDATE post SET title = %s, body = %s'
+ ' WHERE id = %s',
(title, body, id)
)
db.commit()
@@ -80,7 +80,7 @@ def update(id):
def delete(id):
get_post(id)
db = get_db()
- db.execute('DELETE FROM post WHERE id = ?', (id,))
+ db.execute('DELETE FROM post WHERE id = %s', (id,))
db.commit()
return redirect(url_for('blog.index'))
@@ -90,8 +90,8 @@ def delete(id):
def get_post(id, check_author=True):
post = get_db().execute(
'SELECT p.id, title, body, created, author_id, username'
- ' FROM post p JOIN user u ON p.author_id = u.id'
- ' WHERE p.id = ?',
+ ' FROM post p JOIN \"user\" u ON p.author_id = u.id'
+ ' WHERE p.id = %s',
(id,)
).fetchone()