pspp-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pspp-cvs] pspp configure.ac doc/ChangeLog doc/data-io.tex...


From: John Darrington
Subject: [Pspp-cvs] pspp configure.ac doc/ChangeLog doc/data-io.tex...
Date: Mon, 04 Feb 2008 01:24:01 +0000

CVSROOT:        /sources/pspp
Module name:    pspp
Changes by:     <uid#66691>     08/02/04 01:24:01

Modified files:
        .              : configure.ac 
        doc            : ChangeLog data-io.texi files.texi 
        src/data       : ChangeLog automake.mk 
        src/language/data-io: ChangeLog get-data.c 
        src/ui/gui     : automake.mk 
        src/ui/terminal: automake.mk 
        tests          : automake.mk 

Log message:
        Added the postgres reader.  Closes patch #6388

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/configure.ac?cvsroot=pspp&r1=1.70&r2=1.71
http://cvs.savannah.gnu.org/viewcvs/pspp/doc/ChangeLog?cvsroot=pspp&r1=1.50&r2=1.51
http://cvs.savannah.gnu.org/viewcvs/pspp/doc/data-io.texi?cvsroot=pspp&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/pspp/doc/files.texi?cvsroot=pspp&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/ChangeLog?cvsroot=pspp&r1=1.181&r2=1.182
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/automake.mk?cvsroot=pspp&r1=1.32&r2=1.33
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/data-io/ChangeLog?cvsroot=pspp&r1=1.56&r2=1.57
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/data-io/get-data.c?cvsroot=pspp&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/automake.mk?cvsroot=pspp&r1=1.44&r2=1.45
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/terminal/automake.mk?cvsroot=pspp&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/pspp/tests/automake.mk?cvsroot=pspp&r1=1.51&r2=1.52

Patches:
Index: configure.ac
===================================================================
RCS file: /sources/pspp/pspp/configure.ac,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -b -r1.70 -r1.71
--- configure.ac        6 Nov 2007 05:49:04 -0000       1.70
+++ configure.ac        4 Feb 2008 01:24:00 -0000       1.71
@@ -47,6 +47,20 @@
 AM_CONDITIONAL(WITHGUI, test x"$with_gui" != x"no")
 
 
+dnl Checks needed for psql reader
+AC_CHECK_PROG(psql_support, pg_config, yes, no)
+if test x"$psql_support" = x"yes" ; then 
+   AC_DEFINE([PSQL_SUPPORT], 1,
+   [Define to 1 if building in support for reading from postgres databases.])
+   PG_CFLAGS=-I`pg_config --includedir` 
+   AC_SUBST(PG_CFLAGS)
+   PG_LDFLAGS=-L`pg_config --libdir`
+   AC_SUBST(PG_LDFLAGS)
+   PG_LIBS=-lpq
+   AC_SUBST(PG_LIBS)
+fi
+AM_CONDITIONAL(PSQL_SUPPORT, test x"$psql_support" = x"yes")
+
 dnl Checks needed for gnumeric reader
 gnm_support=yes;
 PKG_CHECK_MODULES(LIBXML2, libxml-2.0,,

Index: doc/ChangeLog
===================================================================
RCS file: /sources/pspp/pspp/doc/ChangeLog,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -b -r1.50 -r1.51
--- doc/ChangeLog       11 Nov 2007 05:51:38 -0000      1.50
+++ doc/ChangeLog       4 Feb 2008 01:24:00 -0000       1.51
@@ -1,3 +1,9 @@
+2008-02-04 John Darrington <address@hidden>
+
+       * files.texi data-io.texi: Document the GET DATA TYPE=PSQL
+       option.  Thanks to Ben Pfaff for reviewing this text.
+
+
 2007-11-10  Ben Pfaff  <address@hidden>
 
        * not-implemented.texi: Fix @include command so that it works

Index: doc/data-io.texi
===================================================================
RCS file: /sources/pspp/pspp/doc/data-io.texi,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- doc/data-io.texi    5 Dec 2007 06:40:12 -0000       1.18
+++ doc/data-io.texi    4 Feb 2008 01:24:00 -0000       1.19
@@ -14,6 +14,8 @@
 pertaining to single respondent is a case.
 This chapter examines
 the PSPP commands for defining variables and reading and writing data.
+There are alternative commands to  read data from predefined sources
+such as system files or databases (@xref{GET, GET DATA}.)
 
 @quotation Note
 These commands tell PSPP how to read data, but the data will not

Index: doc/files.texi
===================================================================
RCS file: /sources/pspp/pspp/doc/files.texi,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- doc/files.texi      5 Dec 2007 06:40:12 -0000       1.12
+++ doc/files.texi      4 Feb 2008 01:24:00 -0000       1.13
@@ -163,8 +163,7 @@
 
 @display
 GET DATA
-        /address@hidden,address@hidden
-        /address@hidden'file-name',address@hidden
+        /address@hidden,PSQL,address@hidden
         @dots{}additional subcommands depending on address@hidden
 @end display
 
@@ -181,19 +180,19 @@
 @item GNM
 Spreadsheet files created by Gnumeric (@url{http://gnumeric.org}).
 
address@hidden PSQL
+Relations from PostgreSQL databases (@url{http://postgresql.org}).
+
 @item TXT
 Textual data files in columnar and delimited formats.
 @end table
 
-The FILE subcommand is mandatory for all implemented file types.
-Specify the file to be read as a string file name or (for textual data
-only) a file handle (@pxref{File Handles}).
-
 Each supported file type has additional subcommands, explained in
 separate sections below.
 
 @menu
 * GET DATA /TYPE=GNM::
+* GET DATA /TYPE=PSQL::
 * GET DATA /TYPE=TXT::
 @end menu
 
@@ -222,6 +221,10 @@
 determined from the length of the string it contains, unless the 
 ASSUMEDVARWIDTH subcommand is given.
 
+
+The FILE subcommand is mandatory. Specify the name of the file
+to be read.
+
 The SHEET subcommand specifies the sheet within the spreadsheet file to read.
 There are two forms of the SHEET subcommand.
 In the first form,
@@ -253,6 +256,61 @@
 If omitted, the default value is determined from the length of the 
 string in the first spreadsheet cell for each variable.
 
+
address@hidden GET DATA /TYPE=PSQL
address@hidden Postgres Database Queries
+
address@hidden
+GET DATA /TYPE=PSQL
+         /address@hidden address@hidden
+         /address@hidden@}
+         [/ASSUMEDVARWIDTH=n]
+         [/UNENCRYPTED].
address@hidden display
+
address@hidden postgres
address@hidden databases
+
+The PSQL type is used to import data from a postgres database server.
+The server may be located locally or remotely.
+Variables are automatically created based on the table column names 
+or the names specified in the SQL query.
+Postgres data types of high precision, will loose precision when 
+imported into PSPP.
+Not all the postgres data types are able to be represented in PSPP.
+If a datum cannot be represented a warning will be issued and that 
+datum will be set to SYSMIS.
+
+The CONNECT subcommand is mandatory.
+It is a string specifying the parameters of the database server from
+which the data should be fetched.
+The format of the string is given in the postgres manual
address@hidden://www.postgresql.org/docs/8.0/static/libpq.html#LIBPQ-CONNECT}.
+
+The SQL subcommand is mandatory.
+It must be a valid SQL string to retrieve data from the database.
+
+The ASSUMEDVARWIDTH subcommand specifies the maximum width of string
+variables read  from the database.
+If omitted, the default value is determined from the length of the 
+string in the first value read for each variable.
+
+The UNENCRYPTED subcommand allows data to be retrieved over an insecure
+connection.
+If the connection is not encrypted, and the UNENCRYPTED subcommand is not
+given, then an error will occur.
+Whether or not the connection is
+encrypted depends upon the underlying psql library and the 
+capabilities of the database server.
+
+The following syntax is an example:
address@hidden
+GET DATA /TYPE=PSQL
+     /CONNECT='host=example.com port=5432 dbname=product user=fred passwd=xxxx'
+     /SQL='select * from manufacturer'.
address@hidden example
+
+
 @node GET DATA /TYPE=TXT
 @subsection Textual Data Files
 
@@ -268,9 +326,11 @@
 @cindex text files
 @cindex data files
 When TYPE=TXT is specified, GET DATA reads data in a delimited or
-fixed columnar format, much like DATA LIST (@pxref{DATA LIST}).  The
-FILE subcommand must be specified indicate the name or the file handle
-of the file to be read.
+fixed columnar format, much like DATA LIST (@pxref{DATA LIST}).
+
+The FILE subcommand is mandatory.  Specify the file to be read as 
+a string file name or (for textual data
+only) a file handle (@pxref{File Handles}).
 
 The ARRANGEMENT subcommand determines the file's basic format.
 DELIMITED, the default setting, specifies that fields in the input

Index: src/data/ChangeLog
===================================================================
RCS file: /sources/pspp/pspp/src/data/ChangeLog,v
retrieving revision 1.181
retrieving revision 1.182
diff -u -b -r1.181 -r1.182
--- src/data/ChangeLog  3 Feb 2008 06:47:24 -0000       1.181
+++ src/data/ChangeLog  4 Feb 2008 01:24:00 -0000       1.182
@@ -1,3 +1,8 @@
+2008-02-02  John Darrington <address@hidden>
+
+       psql-reader.c psql-reader.h: New files.  Thanks to Ben Pfaff
+       for reviewing this code.
+       
 2008-02-02  Ben Pfaff  <address@hidden>
 
        Patch #6347.

Index: src/data/automake.mk
===================================================================
RCS file: /sources/pspp/pspp/src/data/automake.mk,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- src/data/automake.mk        25 Nov 2007 06:17:16 -0000      1.32
+++ src/data/automake.mk        4 Feb 2008 01:24:01 -0000       1.33
@@ -1,7 +1,7 @@
 
 noinst_LIBRARIES += src/data/libdata.a
 
-src_data_libdata_a_CPPFLAGS = $(LIBXML2_CFLAGS) $(AM_CPPFLAGS)
+src_data_libdata_a_CPPFLAGS = $(LIBXML2_CFLAGS) $(PG_CFLAGS) $(AM_CPPFLAGS) 
 
 
 src_data_libdata_a_SOURCES = \
@@ -69,6 +69,8 @@
        src/data/por-file-reader.h \
        src/data/por-file-writer.c \
        src/data/por-file-writer.h \
+       src/data/psql-reader.c \
+       src/data/psql-reader.h \
        src/data/scratch-handle.c \
        src/data/scratch-handle.h \
        src/data/scratch-reader.c \

Index: src/language/data-io/ChangeLog
===================================================================
RCS file: /sources/pspp/pspp/src/language/data-io/ChangeLog,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -b -r1.56 -r1.57
--- src/language/data-io/ChangeLog      8 Dec 2007 06:17:00 -0000       1.56
+++ src/language/data-io/ChangeLog      4 Feb 2008 01:24:01 -0000       1.57
@@ -1,3 +1,7 @@
+2008-02-02 John Darrington <address@hidden>
+
+       * get-data.c (cmd_get_data): Support PSQL type.
+
 2007-12-07  Ben Pfaff  <address@hidden>
 
        Patch #6302.

Index: src/language/data-io/get-data.c
===================================================================
RCS file: /sources/pspp/pspp/src/language/data-io/get-data.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- src/language/data-io/get-data.c     5 Dec 2007 06:40:13 -0000       1.3
+++ src/language/data-io/get-data.c     4 Feb 2008 01:24:01 -0000       1.4
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2007 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2008 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -19,6 +19,7 @@
 #include <stdlib.h>
 
 #include <data/gnumeric-reader.h>
+#include <data/psql-reader.h>
 
 #include <data/dictionary.h>
 #include <data/format.h>
@@ -38,6 +39,7 @@
 
 static int parse_get_gnm (struct lexer *lexer, struct dataset *);
 static int parse_get_txt (struct lexer *lexer, struct dataset *);
+static int parse_get_psql (struct lexer *lexer, struct dataset *);
 
 int
 cmd_get_data (struct lexer *lexer, struct dataset *ds)
@@ -53,11 +55,78 @@
     return parse_get_gnm (lexer, ds);
   else if (lex_match_id (lexer, "TXT"))
     return parse_get_txt (lexer, ds);
+  else if (lex_match_id (lexer, "PSQL"))
+    return parse_get_psql (lexer, ds);
 
   msg (SE, _("Unsupported TYPE %s"), lex_tokid (lexer));
   return CMD_FAILURE;
 }
 
+static int
+parse_get_psql (struct lexer *lexer, struct dataset *ds)
+{
+  struct psql_read_info psql;
+  psql.allow_clear = false;
+  psql.conninfo = NULL;
+  psql.str_width = -1;
+  ds_init_empty (&psql.sql);
+
+  lex_force_match (lexer, '/');
+
+  if (!lex_force_match_id (lexer, "CONNECT"))
+    goto error;
+
+  lex_force_match (lexer, '=');
+
+  if (!lex_force_string (lexer))
+    goto error;
+
+  psql.conninfo = strdup (ds_cstr (lex_tokstr (lexer)));
+
+  lex_get (lexer);
+
+  while (lex_match (lexer, '/') )
+    {
+      if ( lex_match_id (lexer, "ASSUMEDSTRWIDTH"))
+       {
+         lex_match (lexer, '=');
+         psql.str_width = lex_integer (lexer);
+         lex_get (lexer);
+       }
+      else if ( lex_match_id (lexer, "UNENCRYPTED"))
+       {
+         psql.allow_clear = true;
+       }
+      else if (lex_match_id (lexer, "SQL"))
+       {
+         lex_match (lexer, '=');
+         if ( ! lex_force_string (lexer) )
+           goto error;
+
+         ds_put_substring (&psql.sql,  lex_tokstr (lexer)->ss);
+         lex_get (lexer);
+       }
+     }
+  {
+    struct dictionary *dict = NULL;
+    struct casereader *reader = psql_open_reader (&psql, &dict);
+
+    if ( reader )
+      proc_set_active_file (ds, reader, dict);
+  }
+
+  ds_destroy (&psql.sql);
+  free (psql.conninfo);
+
+  return CMD_SUCCESS;
+
+ error:
+
+  ds_destroy (&psql.sql);
+  free (psql.conninfo);
+
+  return CMD_FAILURE;
+}
 
 static int
 parse_get_gnm (struct lexer *lexer, struct dataset *ds)

Index: src/ui/gui/automake.mk
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/automake.mk,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -b -r1.44 -r1.45
--- src/ui/gui/automake.mk      29 Jan 2008 11:12:59 -0000      1.44
+++ src/ui/gui/automake.mk      4 Feb 2008 01:24:01 -0000       1.45
@@ -41,6 +41,7 @@
        src/libpspp/libpspp.a \
        $(GTK_LIBS) \
        $(GLADE_LIBS) \
+       $(PG_LIBS) \
        gl/libgl.la \
        @LIBINTL@ @LIBREADLINE@
 

Index: src/ui/terminal/automake.mk
===================================================================
RCS file: /sources/pspp/pspp/src/ui/terminal/automake.mk,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- src/ui/terminal/automake.mk 3 Nov 2007 03:43:12 -0000       1.18
+++ src/ui/terminal/automake.mk 4 Feb 2008 01:24:01 -0000       1.19
@@ -33,6 +33,7 @@
        src/data/libdata.a \
        src/libpspp/libpspp.a \
        $(LIBXML2_LIBS) \
+       $(PG_LIBS) \
        $(LIBICONV) \
        gl/libgl.la \
        @LIBINTL@ @LIBREADLINE@

Index: tests/automake.mk
===================================================================
RCS file: /sources/pspp/pspp/tests/automake.mk,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -b -r1.51 -r1.52
--- tests/automake.mk   3 Feb 2008 06:52:13 -0000       1.51
+++ tests/automake.mk   4 Feb 2008 01:24:01 -0000       1.52
@@ -154,6 +154,10 @@
 dist_TESTS += tests/command/get-data-gnm.sh 
 endif
 
+if PSQL_SUPPORT
+dist_TESTS += tests/command/get-data-psql.sh 
+endif
+
 nodist_TESTS = \
        tests/libpspp/abt-test \
        tests/libpspp/bt-test \




reply via email to

[Prev in Thread] Current Thread [Next in Thread]