title: pass table name as parameter in postgres via python
body: <p>I want to execute postgres query in python.The table name has to be passed as a parameter.Since the table will be created at run time. I have used dict query param style.But i am getting an error.</p>
  
  <pre><code> import psycopg2
  
   CONNECTION_STRING = "dbname='autogist' user='postgres' password=''"
   query = "INSERT INTO %(table)s " +\
              "(vin_id, vin_details_id, price, mileage, dealer_id, created_on, modified_on) " +\
              "VALUES (%(vin_id)s, %(vlookup_id)s, %(price)s, %(mileage)s, %(dealer_id)s,now(),now()) " +\
              "RETURNING id"
  
  
  params = {"table" : "dealer_vehicle_details_2010_01_02",\
                        "vin_id":"3",\
                        "vlookup_id":"403",\
                        "price":"403",\
                        "mileage":"403",\
                        "dealer_id":"276092"
                    }
  
  
   conn=psycopg2.connect(CONNECTION_STRING)
   cursor = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
   cursor.execute(query,params)
  </code></pre>
  
  <p>TRACEBACK:</p>
  
  <pre><code> ERROR: An unexpected error occurred while tokenizing input
  The following traceback may be corrupted or invalid
  The error message is: ('EOF in multi-line statement', (262, 0))
  
  ---------------------------------------------------------------------------
   ProgrammingError                          Traceback (most recent call last)
  
   /home/gridlex/workspace/&lt;ipython console&gt; in &lt;module&gt;()
  
   /usr/local/lib/python2.6/dist-packages/psycopg2/extras.pyc in execute(self, query, vars)
  121         self.index = {}
  122         self._query_executed = 1
  --&gt; 123         return _cursor.execute(self, query, vars)
  124 
  125     def callproc(self, procname, vars=None):
  
  ProgrammingError: syntax error at or near "E'dealer_vehicle_details_2010_01_02'"
  LINE 1: INSERT INTO E'dealer_vehicle_details_2010_01_02' (vin_id, vi...
  </code></pre>