/
__init__.py
71 lines (46 loc) · 1.57 KB
/
__init__.py
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
import datetime
from tdclient import client, connection, errors, version
__version__ = version.__version__
Client = client.Client
def connect(*args, **kwargs):
"""Returns a DBAPI compatible connection object
Args:
type (str): query engine type. "hive" by default.
db (str): the name of database on Treasure Data
result_url (str): result output URL
priority (str): job priority
retry_limit (int): job retry limit
wait_interval (int): job wait interval to check status
wait_callback (callable): a callback to be called on every ticks of job wait
Returns:
:class:`tdclient.connection.Connection`
"""
return connection.Connection(*args, **kwargs)
apilevel = "2.0"
threadsafety = 3
paramstyle = "pyformat"
Error = errors.Error
InterfaceError = errors.InterfaceError
DatabaseError = errors.DatabaseError
DataError = errors.DataError
OperationalError = errors.OperationalError
IntegrityError = errors.IntegrityError
InternalError = errors.InternalError
ProgrammingError = errors.ProgrammingError
NotSupportedError = errors.NotSupportedError
Date = datetime.date
Time = datetime.time
Timestamp = datetime.datetime
def DateFromTicks(ticks):
return datetime.date(*datetime.localtime(ticks)[:3])
def TimeFromTicks(ticks):
return datetime.time(*datetime.localtime(ticks)[3:6])
def TimestampFromTicks(ticks):
return datetime.datetime(*datetime.localtime(ticks)[:6])
def Binary(string):
return bytes(string)
STRING = "string"
BINARY = "string"
NUMBER = "int"
DATETIME = "int"
ROWID = "long"