The eXtremeDB Python wrapper extends the SQL DB API specification by allowing operations with eXtremeDB
sequences
. Asequence
may appear as a result of aSELECT
statement, or, as a parameter inINSERT
orUPDATE
statements.For example, the following statement could be sent to the SQL engine:
>>> cursor.execute("SELECT stamp, low, high FROM Quote WHERE symbol = ?", ('AAA',))The result of this query will be:
>>> row = cursor.fetchone() >>> print "Row is:", row Row is: (<exdb.SequenceIterator object at 0x1008f6610>, <exdb.SequenceIterator object at 0x1008f7610>, <exdb.SequenceIterator object at 0x1008f8610>)Note that the resulting row contains SequenceIterator objects as row values. Regular iterator methods can be applied to this iterator. Note that, except in the case of a query result, the returned iterator will be “not materialized”.
To insert data into a
sequence
, pass data into the SQL statement as a parameter usingarray.array
as a value. For example:>>>cursor.execute('INSERT INTO Quote(symbol, stamp, open, close, high, low, volume) VALUES (?,?,?,?,?,?,?)', ('AAA', array.array('I', timestamps), array.array('f', opens), array.array('f', closes), array.array('f', highs), array.array('f', lows), array.array('I', volumes)))Note that
array.array
is strictly typed, so its type must match thesequence
column type. If it does not match, the resulting behavior is unpredictable.