def postgres_connect(sockdir):
 (user, password) = postgresqlconf.get_user_password()
 try:
  return psycopg2.connect(("host='%s' user='%s' password='%s' connect_timeout='%s' dbname=postgres" % (sockdir, user, password, CONNECT_TIMEOUT)))
 except (EnvironmentError, EOFError, RuntimeError, socket.error) as e:
  utils.err(("Couldn't connect to DB :%s" % e))

def postgres_connect ( sockdir ) : ( user , password ) = postgresqlconf . get_user_password ( ) try : return psycopg2 . connect ( ( "host='%s' user='%s' password='%s' connect_timeout='%s' dbname=postgres" % ( sockdir , user , password , CONNECT_TIMEOUT ) ) ) except ( EnvironmentError , EOFError , RuntimeError , socket . error ) as e : utils . err ( ( "Couldn't connect to DB :%s" % e ) )
connects to the postgresql server using the specified socket file .