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.
See the GitHub pymapd repository for full documentation:
>>> from pymapd import connect>>> con = connect(user="mapd", password= "HyperInteractive", host="my.host.com", dbname="mapd")>>> conConnection(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.rowcount100
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 arrdelay0 -2 -131 -1 -132 -3 13 4 -34 12 7