[Gllug] GTK + PostgresSQL

rich at annexia.org rich at annexia.org
Wed Jan 29 10:20:29 UTC 2003


On Wed, Jan 29, 2003 at 02:59:31PM +0530, Manjush G. Menon wrote:
> hi all,
> 
> I've started developing applications using GTK 
> and postgresSQL. Where will I find resources 
> linking them? im a newbie :-)

The C API to PostgreSQL is documented here:

http://www.postgresql.org/docs/view.php?version=7.3&file=libpq.html

It's crufty, but usable.

I've written some wrappers around libpq which it might be possible to
adapt. They let you program PostgreSQL as if it was more like Perl DBI,
eg:

  st_handle sth;
  int rows, min_id;

  sth = st_prepare_cached
    (dbh,
     "delete from ml_discussion_article "
     "where resid = ? "
     "and current_timestamp - posted_date >= interval ?",
     DBI_INT, DBI_STRING);
  rows = st_execute (sth,
                     resid,
                     psprintf (pool, "%d days", expiry_days));

  if (rows > 0)         /* Any rows actually deleted? */
    {
      sth = st_prepare_cached
        (dbh,
         "select coalesce (min (id), 0) from ml_discussion_article "
         "where resid = ?",
         DBI_INT);
      st_execute (sth, resid);

      st_bind (sth, 0, min_id, DBI_INT);

      sth = st_prepare_cached
        (dbh,
         "delete from ml_discussion_read "
         "where resid = ? "
         "and high <= ?",
         DBI_INT, DBI_INT);
      st_execute (sth, resid, min_id);
    }

which you can find at http://www.annexia.org/freeware/pthrlib/
(Although it's more about writing servers, than writing GTK programs).

Rich.

-- 
Richard Jones, Red Hat Inc. (London, UK) http://www.redhat.com/software/ccm
http://www.annexia.org/ Freshmeat projects: http://freshmeat.net/users/rwmj

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list