views:

252

answers:

2

Hello,

I was wondering if there were any good sources or documents that could explain to me how I can cannot to a PostgreSQL database from within my iPhone application.

Also, if they could go beyond just connecting, and explain how to use PL/SQL and Object Persistence within the Objective C iPhone SDK framework as well, that would be awesome.

Thanks!

-Scott

A: 

For starters you need to compile libpq the library that is used to interact with PostgreSQL. See this link where I went through doing that -> http://stackoverflow.com/questions/1678381/connect-iphone-app-to-postgresql-using-libpq. Make note of my issue in my linked answer. The iphone simulator needs libpq compile for the mac machines processor while the real iphone needs the libpq compiled for the arm processor.

Once you have libpq working you should be able to follow the docs at the postgresql site - http://www.postgresql.org/docs/8.4/interactive/libpq.html.

From what I have found there is no book from start to finish that will cover what you want, you will have to go MacGyver style to figure things out. To learn how to use PL/PGSQL you will want to use the postgresql documents found at www.postgresql.org. There is nothing special about PL/PGSQL being used from the iPhone compared to the desktop. Other than you want to consider your devices constraints and bandwidth/charges. Also the docs on postgresql.org show you how to connect to a database using libpq so there isn't much anyone can do aside from copy the code from the online docs and paste them here for you.

Hope this sheds some light.

StarShip3000
Thanks. That definitely gives me a good basis.
Scott
A: 

Or you can use PGSQLKit for iOS. Look for it on http://www.postgresqlformac.com

Nenad