Skip to content

Working With Pisces Using Other Programming & Scripting Languages

Jon Rocha edited this page May 5, 2017 · 6 revisions

You may connect to a Pisces database using other programming and scripting languages. This guide shows some code snippets for how to connect to, query, and work with a Pisces database using the default SQLite database package.

R

Load the SQLite R-package

library("RSQLite")

sqlite <- dbDriver("SQLite")

Connect to the Pisces DB named tsdatabase.pdb

con = dbConnect(sqlite, dbname="C:/.../tsdatabase.pdb")

Get data for a time period from the jck_qd table

sql = "SELECT * FROM jck_qd WHERE datetime > '1980-01-01 00:00:00' AND datetime < '1980-12-31 00:00:00'"

s2 = dbGetQuery(con, sql)

Do R stuff like plot

y <- s2$value

plot(y)

lines(y)

Python

Load the SQLite Python library

import sqlite3

Connect to the Pisces DB named tsdatabase.pdb

conn = sqlite3.connect("C:/.../tsdatabase.pdb")

cursor = conn.cursor()

Get data for a time period from the jck_qd table

sql = "SELECT * FROM jck_qd WHERE datetime > '1980-01-01 00:00:00' AND datetime < '1980-12-31 00:00:00'"

cursor.execute(sql)

Do Python stuff

print cursor.fetchall()

Clone this wiki locally