Postgres and REALBasic

I’m learning REALBasic and starting to shift over to writing cross platform desktop apps, and one thing I wanted to do is to talk to a postgres database. Here is a quick and dirty bit of code:

dim pgdb as PostgreSQLDatabase
dim sql as string
dim rs as RecordSet

pgdb = new PostgreSQLDatabase
pgdb.DatabaseName = “database.name”
pgdb.Host = “database.hostname”
pgdb.UserName = “user”
pgdb.Password = “password”

if pgdb.Connect then

sql = “SELECT foo FROM bar WHERE woo=’yay’;”
rs = pgdb.SQLSelect(sql)
if rs <> nil then
while not rs.EOF
EditField1.Text = rs.Field(”foo”)
rs.MoveNext()
wend

else
EditField1.Text = “NULL RETVAL”
end if
else
MsgBox “Connect Fail”
end if