|
5 | 5 |
|
6 | 6 | import cs50
|
7 | 7 |
|
8 |
| -""" |
9 | 8 | db = cs50.SQL("sqlite:///foo.db")
|
10 | 9 |
|
11 | 10 | logging.getLogger("cs50").disabled = False
|
| 11 | +logging.getLogger("cs50").setLevel(logging.ERROR) |
12 | 12 |
|
13 |
| -#db.execute("SELECT ? FROM ? ORDER BY ?", "a", "tbl", "c") |
14 |
| -db.execute("CREATE TABLE IF NOT EXISTS bar (firstname STRING)") |
| 13 | +db.execute("CREATE TABLE IF NOT EXISTS bar (firstname STRING UNIQUE)") |
15 | 14 |
|
| 15 | +db.execute("INSERT INTO bar VALUES (?)", "baz") |
16 | 16 | db.execute("INSERT INTO bar VALUES (?)", "baz")
|
17 | 17 | db.execute("INSERT INTO bar VALUES (?)", "qux")
|
18 | 18 | db.execute("SELECT * FROM bar WHERE firstname IN (?)", ("baz", "qux"))
|
19 | 19 | db.execute("DELETE FROM bar")
|
| 20 | + |
20 | 21 | """
|
21 | 22 |
|
22 | 23 | db = cs50.SQL("postgresql://postgres@localhost/test")
|
23 | 24 |
|
24 |
| -""" |
25 | 25 | print(db.execute("DROP TABLE IF EXISTS cs50"))
|
26 | 26 | print(db.execute("CREATE TABLE cs50 (id SERIAL PRIMARY KEY, val VARCHAR(16), bin BYTEA)"))
|
27 | 27 | print(db.execute("INSERT INTO cs50 (val) VALUES('foo')"))
|
|
31 | 31 | print(db.execute("CREATE TABLE cs50 (val VARCHAR(16), bin BYTEA)"))
|
32 | 32 | print(db.execute("INSERT INTO cs50 (val) VALUES('foo')"))
|
33 | 33 | print(db.execute("SELECT * FROM cs50"))
|
34 |
| -""" |
35 | 34 |
|
36 | 35 | print(db.execute("DROP TABLE IF EXISTS cs50"))
|
37 | 36 | print(db.execute("CREATE TABLE cs50 (id SERIAL PRIMARY KEY, val VARCHAR(16), bin BYTEA)"))
|
|
46 | 45 | pass
|
47 | 46 | print(db.execute("INSERT INTO cs50 (val) VALUES('qux')"))
|
48 | 47 | #print(db.execute("DELETE FROM cs50"))
|
| 48 | +
|
| 49 | +""" |
0 commit comments