-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
executable file
·46 lines (33 loc) · 997 Bytes
/
Copy pathrun.py
File metadata and controls
executable file
·46 lines (33 loc) · 997 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
40
41
42
43
44
45
46
#!/usr/bin/env python3
import contextlib
from functools import partial
import logging
import os
import confidence
from boilerplate.app import PostgresApp, Operation
LOG = logging.getLogger(__name__)
def calculate_square_root(app, num):
with app.pgcon.cursor() as cur:
cur.execute('SELECT SQRT(%s)', (num,))
output = cur.fetchone()[0]
print(f'the square root of {num} is {output}')
def get_operations(app):
return [
Operation(
"create_database",
app.setup_database,
run_by_default=False,
),
Operation(
"clean",
app.clear_results,
),
Operation(
"calculate_square_root",
partial(calculate_square_root, app, 16),
),
]
if __name__ == '__main__':
cfg = confidence.load_name('project', 'local')
app = PostgresApp('my_project', get_operations, cfg.database.credentials, cfg.database.schema, cfg.resultdir)
app.run()