Skip to main content

Python library for SciDB streaming

Project description


SciDB 16.9 or newer

Apache Arrow 0.6.0 or newer.

Python 2.7.x, 3.4.x, 3.5.x, 3.6.x or newer.

Required Python packages:



Apache Arrow versions older than 0.8.0 contain a bug which might affect Stream users. The bug manifests on chunks of more than 128 records with null-able values. For more details, see the full bug description here. This bug has been fixed in Apache Arrow version 0.8.0.


Install latest release:

pip install scidb-strm

Install development version from GitHub:

pip install git+

The Python library needs to be installed on the SciDB server. The library needs to be installed on the client as well, if Python code is to be send from the client to the server.

SciDB-Strm Python API and Examples

Once installed the SciDB-Strm Python library can be imported with import scidbstrm. The library provides a high and low-level access to the SciDB stream operator as well as the ability to send Python code to the SciDB server.

High-level access is provided by the function map:

map(map_fun, finalize_fun=None)
Read SciDB chunks. For each chunk, call map_fun and stream its result back to SciDB. If finalize_fun is provided, call it after all the chunks have been processed.

See 0-iquery.txt for a succinct example using the map function.

See for an example using the map function. The Python script has to be copied onto the SciDB instance.

Python code can be send to the SciDB server for execution using the pack_func and read_func functions:

Serialize Python function for use as upload_data in input or load operators.
Read and de-serialize function from SciDB.

See for an example of using the pack_func and read_func functions.

Low-level access is provided by the read and write functions:

Read a data chunk from SciDB. Returns a Pandas DataFrame or None.
Write a data chunk to SciDB.

See for an example using the read and write functions. The Python script has to be copied onto the SciDB instance.

A convenience invocation of the Python interpreter is provided in python_map variable and it is set to:

python -uc "import scidbstrm;"

Finally, see for a more complex example of going throught the steps of using machine larning (preprocessing, training, and prediction).

Debugging Python Code

When debugging Python code executed as part of the stream operator do not use the print function. The stream operator communicates with the Python process using stdout. The print function writes output to stdout. So, using the print function would interfere with the inter-process communication.

Instead, write debug output to stderr using the write function. For example:

import sys

x = [1, 2, 3]

The output is written in the scidb-stderr.log files of each instance, for example:


If using SciDB 18.1 installed in the default location and configured with one server and two instances.

ImportError: No module named

When trying to de-serialize a Python function uploaded to SciDB using pack_func, one might encounter:

ImportError: No module named ...

This error is because dill, the Python serialization library, links the function to the module in which it is defined. This can be resolved in two ways:

  1. Make the named module available on all the SciDB instances

  2. If the module is small, the recursive dill mode can be used. Replace:

    foo_pack = scidbstrm.pack_func(foo)


    foo_pack = numpy.array([dill.dumps(foo, 0, recurse=True)])

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for scidb-strm, version 19.11.2
Filename, size File type Python version Upload date Hashes
Filename, size scidb_strm-19.11.2-py2.py3-none-any.whl (4.9 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size scidb-strm-19.11.2.tar.gz (4.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page