obspy.db example/tutorial

Hi all,

has someone a nice example or tutorial for the obspy.db module?
In particularly I would be interested in how to prepare the database. I would like to start with sqlite, if possible.


Hi Peter,

May someone else can explain you better, but obspy.db was made in SeisHub
(https://github.com/barsch/seishub.core) context and was used mainly for it’s database interface.

It still can be useful outside that context for some of waveform indexing, depending the kind of database you want to do.
But I suspect that it still in the obspy repo for historic reasons.

I hope this help.

Good luck,


Thanks Marlon,

Yes, I would like to use it stand-alone as a starting point for some test, and maybe base some further development on it.

I ran into problems with first testing, so I was asking if there is some more detailed example around. But it seems the problem was due to the fact I was using the development version, instead of 0.9.0. I switched to the latter now and something is happening. Not sure about the final results yet :wink:


Hello Peter & other ObsPy users,

I just saw this exchange last month regarding obspy.db. For anyone interested in using a SQLite (or other) database with seismic data, I've recently posted a project to GitHub that may be useful. The goal is to make it easier to use SQL databases in your Python/ObsPy analysis environment. It's called Pisces.

http://jkmacc-lanl.github.io/pisces/ (docs)
https://github.com/jkmacc-LANL/pisces/ (repository)

Key features:

* It uses SQLAlchemy, so it should work with a number of different database backends, including SQLite.
* You can load waveforms directly from your database as ObsPy Traces.
* You can build database queries using Python objects and methods (SQLAlchemy), not by writing SQL strings (unless you want to).
* Geographic querying.
* Easy importing/exporting of text "flat-file" database tables.

Pisces uses CSS 3.0 database tables, so it should hopefully play well with existing datasets.

Here is an example script that would index your SAC files into a waveform description "wfdisc" table for later querying and waveform retrieval: