Querying SciDB

Import library and connect


In [1]:
from scidbpy import connect
sdb = connect('http://localhost:8080')

Check how many arrays are in SciDB


In [2]:
lenght = len(dir(sdb.arrays))
lenght


Out[2]:
679

Get a random arrayName


In [3]:
from random import randint
arrayName = dir(sdb.arrays)[randint(0, lenght)]
arrayName


Out[3]:
's01604_2883_06_07_14_17'

get the array from SciDB


In [4]:
myArray = sdb.iquery('scan('+arrayName+')', fetch=True, as_dataframe=True)

Plot the x value of the array


In [5]:
import matplotlib.pyplot as plt
simpleArray = myArray["x"];
simpleArray.plot()
plt.show()


List the array


In [6]:
simpleArray


Out[6]:
0        -0.000797
1        -0.000455
2        -0.000228
3        -0.000114
4        -0.000228
5         0.000000
6        -0.000114
7         0.000000
8        -0.000114
9         0.000000
10        0.000000
11        0.000000
12        0.000000
13        0.000000
14        0.000000
15        0.000114
16        0.000000
17        0.000000
18        0.000114
19        0.000228
20        0.000228
21        0.000455
22        0.000455
23        0.000455
24        0.000455
25        0.000455
26        0.000683
27        0.000569
28        0.000683
29        0.000455
            ...   
982009    0.000522
982010    0.000190
982011    0.000569
982012    0.000237
982013    0.000664
982014    0.000285
982015    0.000569
982016    0.000237
982017    0.000522
982018    0.000190
982019    0.000474
982020    0.000142
982021    0.000474
982022    0.000142
982023    0.000095
982024    0.000380
982025    0.000000
982026    0.000332
982027    0.000000
982028    0.000237
982029    0.000047
982030    0.000380
982031    0.000047
982032    0.000380
982033    0.000095
982034    0.000380
982035    0.000000
982036    0.000332
982037    0.000000
982038    0.000237
Name: x, Length: 982039, dtype: float64

In [ ]: