Repository navigation
Expand file tree
/
Copy pathsqlutils.py
More file actions
31 lines (29 loc) · 1.46 KB
/
Copy pathsqlutils.py
File metadata and controls
31 lines (29 loc) · 1.46 KB
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
import contextlib
import psycopg2
def query_columns(cur, query, args = {}):
cur.execute("""
select
*
from
""" + query + """ as a
limit 1
""", args)
return dict((name, ts[0])
for (name, ts) in ((column.name,
[name
for name, t in ((name, getattr(psycopg2, name))
for name in ("Date",
"Time",
"Timestamp",
"DateFromTicks",
"TimeFromTicks",
"TimestampFromTicks",
"Binary",
"STRING",
"BINARY",
"NUMBER",
"DATETIME",
"ROWID"))
if column.type_code == t])
for column in cur.description)
if ts)