input: Write a python function to connect to a PostgreSQL database and handle connection errors.
  assert connect_to_db("dbname='testdb' user='user1' host='localhost' password='wrongpassword'") == "Connection failed"
  assert connect_to_db("dbname='nonexistentdb' user='user1' host='localhost' password='password'") == "Connection failed"
  assert connect_to_db("dbname='testdb' user='user1' host='localhost' password='password'") == "Connection successful"
output: import psycopg2
  from psycopg2 import OperationalError
  
  def connect_to_db(conn_str):
      try:
          conn = psycopg2.connect(conn_str)
          conn.close()
          return "Connection successful"
      except OperationalError:
          return "Connection failed"