Skip to content
This repository

Access to Postgresql database from IDL

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 LICENSE
Octocat-spinner-32 Makefile
Octocat-spinner-32 README
Octocat-spinner-32 pgsql_query.c
Octocat-spinner-32 pgsql_query.dlm
Octocat-spinner-32 pgsql_query.h
Octocat-spinner-32 pgsql_query_util.c
Octocat-spinner-32 types.h
README
This is the module for accesing Postgresql database from IDL. 
It was mostly written by Erin Sheldon. 
I have extracted it from sdssidl ( http://code.google.com/p/sdssidl/ ) and made the installation simpler.


INSTALLATION: 
The pre-requisite is that you have to download the postgresql tarball
from http://www.postgresql.org/ftp/source/ and put it in this directory (no
need to extract it).
You also should have idl in your path

After that just run
   make

This will create the directory called DLM which will have a dynamically
loadable IDL module. 
You can put this directory anywhere and add the path to it to the 
environmental variable IDL_DLM_PATH, e.g.
export IDL_DLM_PATH=some_path/DLM

After that in any IDL session you should be able to use pgsql_query()
function

IDL> res=pgsql_query('select ra,dec from sdssdr7.phototag limit 10',connect_info='host=some_host user=some_user password=some_password dbname=some_dbname')
% Loaded DLM: PGSQL_QUERY.
IDL> print, res
{       329.12152       44.397910}{       329.14333       44.390562}{329.14613       44.392761}{
       329.14461       44.392961}{       329.14460       44.392961}{ 329.14893       44.393050}{
       329.14863       44.393803}{       329.14229       44.395501}{ 329.14278       44.396347}{
       329.15523       44.395887}
IDL> help,res,/str
** Structure <2948e08>, 2 tags, length=16, data length=16, refs=1:
   RA              DOUBLE           329.12152
   DEC             DOUBLE           44.397910


IF you don't want to type all the time the connection info, you should 
define the environmental variables:
PGHOST PGDATABASE PGUSER PGPASSWORD
export PGHOST=hostname_of_the_database_server
export PGDATABASE=dbname
export PGUSER=your_username
export PGPASSWORD=your_password

If you define these, you can easily query without additional arguments:
Running the .idl_startup script...

IDL> res=pgsql_query('select ra,dec from sdssdr7.phototag limit 10')

Something went wrong with that request. Please try again.