Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. >>> import psycopg2
  2. >>> conn = pyscopg2.connect("dbname=phil user=phil")
  3. >>> cur = conn.cursor()
  4. >>> cur.execute("CREATE TABLE some_table(id serial PRIMARY KEY, some_val text);")
  5. >>> cur.execute("CREATE FUNCTION some_func(val text) RETURNS int AS $$ INSERT INTO some_table(some_val) SELECT $1 RETURNING id; $$LANGUAGE SQL;")
  6. >>> cur.callproc("some_func", {"val": "fun times"})
  7. >>> cur.fetchone()
  8. (1,)
  9. >>> cur.execute("CREATE FUNCTION some_other_func(text) RETURNS int AS $$ INSERT INTO some_table(some_val) SELECT $1 RETURNING id; $$LANGUAGE SQL;")
  10. >>> cur.callproc("some_other_func", {"val": "fun times"})
  11. Traceback (most recent call last):
  12. File "<stdin>", line 1, in <module>
  13. psycopg2.ProgrammingError: function some_other_func(val => unknown) does not exist
  14. LINE 1: SELECT * FROM some_other_func("val":='fun times')
  15. ^
  16. HINT: No function matches the given name and argument types. You might need to add explicit type casts.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement