forked from pysprings/bottle-wiki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbfunctions.py
45 lines (35 loc) · 1.06 KB
/
dbfunctions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import sqlite3
conn = sqlite3.connect('wiki.db')
cur = conn.cursor()
# Create if not exists Articles table
tablesql = """
CREATE TABLE IF NOT EXISTS articles (
subject varchar PRIMARY KEY
, article_text VARCHAR NOT NULL
, created_on DATETIME DEFAULT CURRENT_TIMESTAMP
, updated_on DATETIME
);
"""
cur.execute(tablesql)
conn.commit()
def create_article(subject, body):
"""
This function should insert into the table articles, a new article containing the text and subject specified.
"""
cur.execute("INSERT INTO articles (subject, article_text) VALUES ('%s','%s')" % (subject,body))
conn.commit()
pass
def update_article(subject, article_text):
"""
This function should update the article in table articles with subject specified.
It should set the article_text to the text specified.
An error should be returned if the subject does not exist.
"""
pass
def search_article(subject, strict=False):
"""
This article should return a list of subjects that contain the subject text given.
Strict should return only exact match
Case?
"""
pass