title: Python: malformed array literal when inserting a string
body: <p>I'm trying to read from a file and insert the data to a postgresql table in python using the <code>psycopg2</code>.</p>
  
  <p>Here's the function I wrote:</p>
  
  <pre><code>def insert(file, table, col, conn):
      sql = "INSERT INTO "+table+"("+col+") VALUES(%s)"
      cur = conn.cursor()
      with open(os.path.join(DEFAULTS_FOLDER, file)) as fp:
          line = fp.readline()
          while line:
              cur.execute(sql, (line.rstrip(),))
              line = fp.readline()
          conn.commit()
          cur.close()
      return
  </code></pre>
  
  <p>For some reason I get an error:</p>
  
  <pre><code>cur.execute(sql, (line.rstrip(),)) psycopg2.DataError: malformed array literal: "hello" LINE 1: INSERT INTO greetings(gname) VALUES('hello')
  </code></pre>
  
  <p>I also tried to insert a plain string and I still get the same error.</p>