Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> import psycopg2
- >>> conn = pyscopg2.connect("dbname=phil user=phil")
- >>> cur = conn.cursor()
- >>> cur.execute("CREATE TABLE some_table(id serial PRIMARY KEY, some_val text);")
- >>> cur.execute("CREATE FUNCTION some_func(val text) RETURNS int AS $$ INSERT INTO some_table(some_val) SELECT $1 RETURNING id; $$LANGUAGE SQL;")
- >>> cur.callproc("some_func", {"val": "fun times"})
- >>> cur.fetchone()
- (1,)
- >>> cur.execute("CREATE FUNCTION some_other_func(text) RETURNS int AS $$ INSERT INTO some_table(some_val) SELECT $1 RETURNING id; $$LANGUAGE SQL;")
- >>> cur.callproc("some_other_func", {"val": "fun times"})
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- psycopg2.ProgrammingError: function some_other_func(val => unknown) does not exist
- LINE 1: SELECT * FROM some_other_func("val":='fun times')
- ^
- 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