Scidbpy list arrays fails and how to download array to numpy


#1

We received the following query from one of our users:

I’m trying to use SciDb-Py module for connect a script to Scidb but I have some problems.

The first one is in the following example:

from scidbpy import connect
import numpy as np
import time

sdb = connect('http://localhost:8080')

sdb.query("store(build(<v:double>[i=1:10,10,0,j=1:500,5,0],0),A)")

sdb.query("create array matriz <valor:int64>[i=0:3,1,0,j=0:3,1,0]")

X = sdb.random(10, persistent=False)  # default
A = sdb.afl.list( 'arrays', False )
print A

I want to know what is the arrays i have in my database, but the query fail.

Other thing that i want to do is, for example in my database i have two arrays (‘array1’ and ‘array2’), how i do for get all the data in a numpy array in python?


#2

Here is the solution:

You can try the following code to view the lists of arrays (note that you need to escape the quote character):

A = sdb.afl.list( "\'arrays\'", False )
print A.toarray()
print A.todataframe()

To download any array to Python, say your array A:

Ap = sdb.wrap_array("A")
Ap.toarray()
Ap.todataframe()