PQconnectdbParams Function

public function PQconnectdbParams(keywords, values, expand_dbname) result(conn)

Connect to the database server with connection infomation provided as pairs of keywords and values arrays.

Example

   character(16) :: keywords(3), values(3)
   type(c_ptr) :: conn

   keywords(1) = 'host';   values(1) = 'localhost'
   keywords(2) = 'user';   values(2) = 'postgres'
   keywords(3) = 'dbname'; values(3) = 'postgres'

   conn = PQconnectdbParams(keywords, values, 0)

   ! 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) :: keywords(:)

Keywords, such as host, hostaddr, dbname, user, password, etc.

character(len=*), intent(in) :: values(:)

The array of each value corresponding to that keyword.

integer :: expand_dbname

Return Value type(c_ptr)


Contents