pymapd
The pymapd client interface provides a python DB API 2.0-compliant OmniSci interface. In addition, it provides methods to get results in the Apache Arrow-based GDF format for efficient data interchange.
>>> from pymapd import connect
>>> con = connect(user="mapd", password= "HyperInteractive", host="my.host.com", dbname="mapd")
>>> con
Connection(omnisci://omnisci:***@my.host.com:6274/omnisci?protocol=binary)
>>> c = con.cursor()
>>> c
<pymapd.cursor.Cursor object at 0x7f0117fe2490>
>>> c.execute("SELECT depdelay, arrdelay FROM flights LIMIT 100")
<pymapd.cursor.Cursor object at 0x7f0117fe2490>
>>> c.rowcount
100
The list is a named tuple with attributes required by the specification. There is one entry per returned column, and we fill the
name
, type_code
, and null_ok
attributes.>>> c.description
[Description(name=u'depdelay', type_code=0, display_size=None, internal_size=None, precision=None, scale=None, null_ok=True), Description(name=u'arrdelay', type_code=0, display_size=None, internal_size=None, precision=None, scale=None, null_ok=True)]
>>> result = list(c)
>>> result[:5]
[(1, 14), (2, 4), (5, 22), (-1, 8), (-1, -2)]
>>> from pymapd import connect
>>> con = connect(user="mapd", password="HyperInteractive", host="localhost",
... dbname="mapd")
>>> query = "SELECT depdelay, arrdelay FROM flights_2008_10k limit 100"
>>> df = con.select_ipc_gpu(query)
>>> df.head()
depdelay arrdelay
0 -2 -13
1 -1 -13
2 -3 1
3 4 -3
4 12 7
Last modified 2yr ago