title: Problems calling a postgresql function from python
body: <p>I have a .sql file which I load using the psql command line. This file contains all my function definitions. I call functions defined in this file from a python script. </p>
  
  <p>I'm facing a weird problem. I have declared a function in my .sql file as follows:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION Add_to_stroke(my_stroke VARCHAR(50))
  RETURNS VOID
  AS $$
      BEGIN
          INSERT INTO stroke VALUES (my_stroke);
      END $$
  LANGUAGE plpgsql
  VOLATILE;
  </code></pre>
  
  <p>I'm calling this function from my python file as follows:</p>
  
  <pre><code>conn = psycopg2.connect("dbname=postgres user=postgres password=psswd")
  cur = conn.cursor()
  cur.callproc('Add_to_stroke','freestyle')
  </code></pre>
  
  <p>I get the following error message:</p>
  
  <pre><code> ProgrammingError: function add_to_stroke(unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown) does not exist
      LINE 1: SELECT * FROM add_to_stroke('f','r','e','e','s','t','y','l',...
                        ^
  HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
  </code></pre>
  
  <p>When I call this function from my psql command line as follows, it works properly:</p>
  
  <pre><code>SELECT Add_to_stroke('Freestyle')
  </code></pre>
  
  <p>Also, I tried to display all the functions that I've created and there is a function Add_to_stroke.</p>
  
  <p>I was initially thinking that this problem arises due to some conversion from string to something else issue. However, when I call functions for other tables which have variables as VARCHAR(50) in a similar way, it works. The only difference between those tables and this table is that those tables have more than one attribute and this one has only one attribute. </p>
  
  <p>I replaced the cur.callproc() line with the following line:</p>
  
  <pre><code>foo = 'Freestyle'
   cur.execute("SELECT add_to_stroke(%s)",(foo,))
  </code></pre>
  
  <p>And now it works properly.</p>
  
  <p>However, I don't want to use cur.execute since I have to explicitly write an sql statement myself. The assumption here is that the person using python has no idea how to write an sql and only knows the function names and the input parameters to the function. Strange as it may sound, this is a requirement.</p>
  
  <p>What am I doing wrong?</p>