title: Passing command line argument to Presto Query
body: <p>I m a newbie to python. I want to pass a command-line argument to my presto query which is inside a function and then writes the result as a CSV file. But when I try to run it on the terminal it says '<code>Traceback (most recent call last): File &quot;function2.py&quot;, line 3, in &lt;module&gt; from pyhive import presto ModuleNotFoundError: No module named 'pyhive'</code></p>
  <p>The pyhive requirement is already satisfied. Please find attached my code:</p>
  <pre><code>from sys import argv
  import argparse
  from pyhive import presto
  import prestodb
  import csv
  import sys
  
  
  import pandas as pd
  
  connection = presto.connect(host='xyz',port=8889,username='test')
  cur = connection.cursor()
  print('Connection Established')
  
  
  def func1(object,start,end):
      object = argv[1]
      start = argv[2]
      end = argv[3]
      result = cur.execute(&quot;&quot;&quot;
      with map_date as 
      (
       SELECT 
       object, 
       epoch,
       timestamp,
       date,
       map_agg(name, value) as map_values
      from hive.schema.test1
      where object = '${object}' 
      and (epoch &gt;= '${start}' and epoch &lt;= '${end}')
      and name in ('x','y')
      GROUP BY object,epoch,timestamp,date
      order by timestamp asc
      )
      SELECT
        epoch
      , timestamp
      , CASE WHEN element_at(map_values, 'x') IS NOT NULL THEN map_values['x'] ELSE NULL END AS x
      , CASE WHEN element_at(map_values, 'y') IS NOT NULL THEN map_values['y'] ELSE NULL END AS y
      , object
      , date AS date
      from map_date
      &quot;&quot;&quot;)
  rows = cur.fetchall()
  print('Query Finished')     #Returns the list with one entry for each record
  fp = open('/Users/xyz/Desktop/Python/function.csv', 'w')
  print('File Created')
  myFile = csv.writer(fp)
  colnames = [desc[0] for desc in cur.description]     #store the headers in variable called 'colnames'
  myFile.writerow(colnames)    #write the header to the file
  myFile.writerows(rows)
  fp.close()
  
  func1(object,start,end)
  
  cur.close()
  connection.close()
  </code></pre>
  <p>How can I pass the command line argument to my Presto query which is written inside a function?
  Any help is much appreciated. Thank you In advance!</p>