Thread: DB connectivity using C

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    141

    DB connectivity using C

    Hi,

    Are there any methods to connect to a database (say postgresql) using C?


    Thanks,
    Angshu

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659

  3. #3
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    also google for ODBC, which is probably the most common way.

  4. #4
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    postgresql's homepage has an ODBC driver which you can download.

  5. #5
    !anExpert
    Join Date
    Mar 2005
    Location
    pa
    Posts
    155
    there are also docs for the c api to postgres

    thank you google.

  6. #6
    ex-DECcie
    Join Date
    Dec 2005
    Posts
    125
    Quote Originally Posted by xhi
    there are also docs for the c api to postgres

    thank you google.

    If you use libpq (and I think it is pretty good, I work with it on a daily basis) you have to remember to use the PQclear call to free memory that PostgreSQL allocates on your behalf (usually results and connection pointers, PGres* and PGconn*) so that you eliminate memory leaks.

    That's not always intuitive if you use the same pointer over and over again.

    Good luck!

  7. #7
    Registered User
    Join Date
    Dec 2007
    Posts
    3
    Quote Originally Posted by fgw_three View Post
    If you use libpq (and I think it is pretty good, I work with it on a daily basis) you have to remember to use the PQclear call to free memory that PostgreSQL allocates on your behalf (usually results and connection pointers, PGres* and PGconn*) so that you eliminate memory leaks.

    That's not always intuitive if you use the same pointer over and over again.

    Good luck!
    Good Advice, thanks.

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Please read the forum rules, and avoid bumping long-dead threads.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem with bootstrap
    By abachler in forum Linux Programming
    Replies: 0
    Last Post: 01-23-2009, 10:41 PM
  2. Replies: 10
    Last Post: 05-18-2006, 11:23 PM
  3. Assembly Tutorials
    By JoshR in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 06-11-2005, 09:56 AM
  4. if is faster than switch?
    By skorman00 in forum C++ Programming
    Replies: 32
    Last Post: 03-06-2004, 01:15 PM
  5. Need help comparing db field values in c++
    By misha in forum C++ Programming
    Replies: 18
    Last Post: 07-09-2003, 09:37 AM