PQconnectdb Function

public function PQconnectdb(conninfo) result(conn)

Connect to the database server with the provided connection string conninfo.

Example

   character(:), allocatable :: conninfo
   type(c_ptr) :: conn

   conninfo = "host=localhost user=postgres dbname=postgres password=foobar" 

   conn = PQcoonectdb(conninfo)

   ! Error handling
   if (PQstatus(conn) /= CONNECTION_OK) then
      print *, PQerrorMessage(conn)
   end if

cf. PostgreSQL Documentation

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: conninfo

PostgreSQL connection string

Return Value type(c_ptr)


Contents