Git Product home page Git Product logo

pg_idl's Introduction

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')

pg_idl's People

Contributors

mandrakos avatar segasai avatar

Watchers

 avatar  avatar

pg_idl's Issues

Segfault in GetArrayDims

Appears to happen when all rows of a column are null? Static analysis from splint:

pgsql_query_util.c: (in function GetArrayDims)
pgsql_query_util.c:438:30: Function ntohl expects arg 1 to be uint32_t gets
int32: (int32 )(mptr + 0 * sizeof(int32))
pgsql_query_util.c:440:38: Return value (type int) ignored: fflush(stdout)
pgsql_query_util.c:445:36: Function calloc expects arg 1 to be size_t gets long
int: ndim + 1
To allow arbitrary integral types to match long unsigned, use +longintegral.
pgsql_query_util.c:446:9: Index of possibly null pointer dims: dims
A possibly null pointer is dereferenced. Value is either the result of a
function which may return null (in which case, code should check it is not
null), or a global, parameter or structure field declared with the null
qualifier. (Use -nullderef to inhibit warning)
pgsql_query_util.c:445:16: Storage dims may become null
pgsql_query_util.c:450:35: Function ntohl expects arg 1 to be uint32_t gets
int32: (int32 )(mptr + pos * sizeof(int32))
pgsql_query_util.c:453:60: Return value (type int) ignored: fflush(stdout)
pgsql_query_util.c:459:49: Return value (type int) ignored: fflush(stdout)
pgsql_query_util.c:461:11: Null storage dims returned as non-null: (dims)
Function returns a possibly null pointer, but is not declared using
/
@null@
/ annotation of result. If function may return NULL, add /
@null@
/
annotation to the return value declaration. (Use -nullret to inhibit warning)
pgsql_query_util.c:435:20: Storage dims becomes null

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.