Re: Accesing Databases



Hi to all! I will develop a simple application, that will be like an
addressbook. I am having one big problem, I do not know the functions to
access to a mysql or postgresql database. I know those functions that work
with php and I also have a good unsertanding of databases and sql language,
so the only problem that I have is that I do not know the names of the
functions to access a database and also the data types returned by them. One
more thing... which other 'include' I will have to make? Can you give me a
hint?

you'll need to look at the MySQL and PostgreSQL docs to see their
respective APIs. look at http://www.mysql.org and www.postgresql.org

Yes, you need to read the documentation,
About two years ago, I played a bit with PostgreSQL,
and I wrote a few very small tests to acess databases.
At that time, the general procedure was:

1) Write your C program, say test.c; SQL instructions are 
embedded in the code (they are preceded by the words: exec sql).

2) Run a translator (each language had his one, for C
it was ecpg), which translates all sql commands after
exec instructions, so in the end you have insert.c
(with calls to Postgres libs included by the translator):

ecpg -o insert.c test.c -Ilocal/include

Finally compile your new insert.c file:

cc -o insert -Ilocal/include -Llocal/lib insert.c -lecpg -lpq -lcrypt

Run the executable and there you are, new data has 
been inserted in your database by your code!

Things probably changed a lot, read the documentation.

Carlos




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