forked from python-postgres/be
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdo.sql
More file actions
39 lines (35 loc) · 671 Bytes
/
Copy pathdo.sql
File metadata and controls
39 lines (35 loc) · 671 Bytes
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
DO $$
import Postgres
sqlexec("""
CREATE TABLE created_from_do (i int);
INSERT INTO created_from_do VALUES (1004);
""")
$$ LANGUAGE python;
SELECT * FROM created_from_do;
DO $$
import Postgres
Postgres.ERROR("do-raised-error")
$$ LANGUAGE python;
DO $$
import Postgres
x = xact()
x.__enter__()
$$ LANGUAGE python;
-- Now for something more interesting...
DO $$
prepare("""
DO $more$
import Postgres
Postgres.WARNING("sub-do")
$more$ LANGUAGE python;
""")()
$$ LANGUAGE python;
-- Now for something even more interesting...
DO $$
prepare("""
DO $more$
import Postgres
Postgres.ERROR("how does the traceback look?")
$more$ LANGUAGE python;
""")()
$$ LANGUAGE python;