/
TODO.txt
83 lines (61 loc) · 2.41 KB
/
TODO.txt
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
Unsorted
========
- Don't allow `with con` at all; require `with con.begin()` so that:
1. autocommit is broken out of
2. you can't confuse the connection pooling with transactions.
with con:
# What is even happening here?
with con.begin()
# This is clear.
- Standardize a few more things:
con.isolation_level
con.transaction_status
- Query builders.
dbx.select('column', dbx.alias('count(1)', 'count'), from_='table').join('table2', on='some condition').where(dbx.or_('foo = {}', 1)).group_by('bar', 'desc')
dbx.upsert('table', dict(foo='new_value'), where='id = blah')
dbx.bind('a = {}', 'apple') for generic use around the place
- Datetime and other parsing should be on by default for SQLite stuff.
- Pull in con.tables(), con.columns(table), etc., from mmtransfer.
- Engine/Connection.migrate(table, functions)
- Stored procedures.
proc = Procedure(base_name, contents, language='sql')
name = base_name + '_' + md5(contents) + language
proc(con, params, create_if_missing=True) -> result
- Postgres events.
- Base class it text events.
- Mixin or serializer='json' brings JSON events.
- Mixin brings a backfill table and stored procedures.
We could have a base implementation that has a dbapix_notifies table.
- Our own type registering system.
- dbx.SQL('literal SQL')
- Sqlite and Psycopg2 don't touch %s if args is None, but our handling of it
means that they might.
>>> cur.execute("select '%s'")
>>> list(cur)
[('%s',)]
>>> cur.execute("select '%s'", [1])
>>> list(cur)
[('1',)]
>>> cur.execute("select '%s'", [])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: list index out of range
Connection Management Confusion
===============================
- `get_connection` vs `connect` is not clear, alternatives include:
- `take_connection` vs `borrow_connection`
- `auto_connection()`
- `auto_connect()`
- `connection_context()`
- a method vs calling the engine:
with engine() as con:
pass
- calling the pool:
with engine.pool() as con:
pass
x a method vs a direct context:
# Note that this can't work as I don't think we can really track
# the state on this to be sure we close it without doing shit like
# using sys._getframe to maintain it.
with engine as con:
pass