Why doesn't Django see the postgres functionAre function names in PostgreSQL case insensitive?Psycopg2 callproc and sql parametersString passed into cursor.callproc becomes unknown (psycopg2, python 2.7, postgres 9.3)Calling a function of a module by using its name (a string)Using global variables in a functionPython join: why is it string.join(list) instead of list.join(string)?How to make a chain of function decorators?Does Django scale?How to check Django versiondifferentiate null=True, blank=True in djangoWhy is reading lines from stdin much slower in C++ than Python?Why does Python code run faster in a function?Why is “1000000000000000 in range(1000000000000001)” so fast in Python 3?
What is the term when two people sing in harmony, but they aren't singing the same notes?
Do I need a multiple entry visa for a trip UK -> Sweden -> UK?
Ways to speed up user implemented RK4
Was Spock the First Vulcan in Starfleet?
Is it okay / does it make sense for another player to join a running game of Munchkin?
What is the oldest known work of fiction?
Using parameter substitution on a Bash array
Mapping a list into a phase plot
How was Earth single-handedly capable of creating 3 of the 4 gods of chaos?
Is there a good way to store credentials outside of a password manager?
Irreducibility of a simple polynomial
How can I use the arrow sign in my bash prompt?
Why Were Madagascar and New Zealand Discovered So Late?
What's a natural way to say that someone works somewhere (for a job)?
I'm in charge of equipment buying but no one's ever happy with what I choose. How to fix this?
Go Pregnant or Go Home
Coordinate position not precise
There is only s̶i̶x̶t̶y one place he can be
How could Frankenstein get the parts for his _second_ creature?
Modify casing of marked letters
Time travel short story where a man arrives in the late 19th century in a time machine and then sends the machine back into the past
Generic lambda vs generic function give different behaviour
voltage of sounds of mp3files
Increase performance creating Mandelbrot set in python
Why doesn't Django see the postgres function
Are function names in PostgreSQL case insensitive?Psycopg2 callproc and sql parametersString passed into cursor.callproc becomes unknown (psycopg2, python 2.7, postgres 9.3)Calling a function of a module by using its name (a string)Using global variables in a functionPython join: why is it string.join(list) instead of list.join(string)?How to make a chain of function decorators?Does Django scale?How to check Django versiondifferentiate null=True, blank=True in djangoWhy is reading lines from stdin much slower in C++ than Python?Why does Python code run faster in a function?Why is “1000000000000000 in range(1000000000000001)” so fast in Python 3?
There is such a function:
def getNearestNotes(request, longitude, latitude):
if request.method == 'GET':
c = connection.cursor()
r = None
try:
c.callproc('GetAllNotes', (float(longitude), float(latitude)))
r = c.fetchall()
finally:
c.close()
return HttpResponse(str(r))
else:
return HttpResponse('needGetMethod')
It should call such a function in the postgresql database:
create function "GetAllNotes"(long numeric, lat numeric)
returns TABLE
(
UserId integer,
UserName character varying,
NoteName character varying,
NoteLong double precision,
NoteLat double precision
)
language plpgsql
as
$$
BEGIN
RETURN query (SELECT Notes."UserId", Users."Name", Notes."Name",
Notes."Longitude", Notes."Latitude"
FROM Notes
INNER JOIN Users ON Notes."UserId" = Users."Id"
WHERE (point(long, lat) <@> point(Notes."Longitude",
Notes."Latitude") <= 0.124274));
END
$$;
alter function "GetAllNotes"(numeric, numeric) owner to postgres;
But when calling this function, django gives an error -
function getallnotes(numeric, numeric) does not exist
LINE 1: SELECT * FROM GetAllNotes(28.0,23.0)
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
The base is connected.
But if I do this -
c.execute("SELECT routine_name FROM information_schema.routines WHERE routine_type='FUNCTION' AND specific_schema='public'")
- then the 'GetAllNotes' function will be listed
r = c.fetchone()
python django psycopg2
add a comment |
There is such a function:
def getNearestNotes(request, longitude, latitude):
if request.method == 'GET':
c = connection.cursor()
r = None
try:
c.callproc('GetAllNotes', (float(longitude), float(latitude)))
r = c.fetchall()
finally:
c.close()
return HttpResponse(str(r))
else:
return HttpResponse('needGetMethod')
It should call such a function in the postgresql database:
create function "GetAllNotes"(long numeric, lat numeric)
returns TABLE
(
UserId integer,
UserName character varying,
NoteName character varying,
NoteLong double precision,
NoteLat double precision
)
language plpgsql
as
$$
BEGIN
RETURN query (SELECT Notes."UserId", Users."Name", Notes."Name",
Notes."Longitude", Notes."Latitude"
FROM Notes
INNER JOIN Users ON Notes."UserId" = Users."Id"
WHERE (point(long, lat) <@> point(Notes."Longitude",
Notes."Latitude") <= 0.124274));
END
$$;
alter function "GetAllNotes"(numeric, numeric) owner to postgres;
But when calling this function, django gives an error -
function getallnotes(numeric, numeric) does not exist
LINE 1: SELECT * FROM GetAllNotes(28.0,23.0)
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
The base is connected.
But if I do this -
c.execute("SELECT routine_name FROM information_schema.routines WHERE routine_type='FUNCTION' AND specific_schema='public'")
- then the 'GetAllNotes' function will be listed
r = c.fetchone()
python django psycopg2
Could there be a mismatch betweennumeric
and the floats that you are passing in? Check whether you get the same error with decimals, e.g.from decimal import Decimal; c.callproc('GetAllNotes', (Decimal('51.5'), Decimal('0.0')))
– Alasdair
Mar 7 at 11:59
1
@Alasdair Yes. I get the same error. And when I set float into the function, I get the same error.
– xomem
Mar 7 at 12:13
See also stackoverflow.com/questions/3202763/… and stackoverflow.com/questions/28409134/…
– Risadinha
Mar 7 at 14:06
add a comment |
There is such a function:
def getNearestNotes(request, longitude, latitude):
if request.method == 'GET':
c = connection.cursor()
r = None
try:
c.callproc('GetAllNotes', (float(longitude), float(latitude)))
r = c.fetchall()
finally:
c.close()
return HttpResponse(str(r))
else:
return HttpResponse('needGetMethod')
It should call such a function in the postgresql database:
create function "GetAllNotes"(long numeric, lat numeric)
returns TABLE
(
UserId integer,
UserName character varying,
NoteName character varying,
NoteLong double precision,
NoteLat double precision
)
language plpgsql
as
$$
BEGIN
RETURN query (SELECT Notes."UserId", Users."Name", Notes."Name",
Notes."Longitude", Notes."Latitude"
FROM Notes
INNER JOIN Users ON Notes."UserId" = Users."Id"
WHERE (point(long, lat) <@> point(Notes."Longitude",
Notes."Latitude") <= 0.124274));
END
$$;
alter function "GetAllNotes"(numeric, numeric) owner to postgres;
But when calling this function, django gives an error -
function getallnotes(numeric, numeric) does not exist
LINE 1: SELECT * FROM GetAllNotes(28.0,23.0)
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
The base is connected.
But if I do this -
c.execute("SELECT routine_name FROM information_schema.routines WHERE routine_type='FUNCTION' AND specific_schema='public'")
- then the 'GetAllNotes' function will be listed
r = c.fetchone()
python django psycopg2
There is such a function:
def getNearestNotes(request, longitude, latitude):
if request.method == 'GET':
c = connection.cursor()
r = None
try:
c.callproc('GetAllNotes', (float(longitude), float(latitude)))
r = c.fetchall()
finally:
c.close()
return HttpResponse(str(r))
else:
return HttpResponse('needGetMethod')
It should call such a function in the postgresql database:
create function "GetAllNotes"(long numeric, lat numeric)
returns TABLE
(
UserId integer,
UserName character varying,
NoteName character varying,
NoteLong double precision,
NoteLat double precision
)
language plpgsql
as
$$
BEGIN
RETURN query (SELECT Notes."UserId", Users."Name", Notes."Name",
Notes."Longitude", Notes."Latitude"
FROM Notes
INNER JOIN Users ON Notes."UserId" = Users."Id"
WHERE (point(long, lat) <@> point(Notes."Longitude",
Notes."Latitude") <= 0.124274));
END
$$;
alter function "GetAllNotes"(numeric, numeric) owner to postgres;
But when calling this function, django gives an error -
function getallnotes(numeric, numeric) does not exist
LINE 1: SELECT * FROM GetAllNotes(28.0,23.0)
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
The base is connected.
But if I do this -
c.execute("SELECT routine_name FROM information_schema.routines WHERE routine_type='FUNCTION' AND specific_schema='public'")
- then the 'GetAllNotes' function will be listed
r = c.fetchone()
python django psycopg2
python django psycopg2
edited Mar 7 at 14:07
Risadinha
9,54115764
9,54115764
asked Mar 7 at 11:43
xomemxomem
277
277
Could there be a mismatch betweennumeric
and the floats that you are passing in? Check whether you get the same error with decimals, e.g.from decimal import Decimal; c.callproc('GetAllNotes', (Decimal('51.5'), Decimal('0.0')))
– Alasdair
Mar 7 at 11:59
1
@Alasdair Yes. I get the same error. And when I set float into the function, I get the same error.
– xomem
Mar 7 at 12:13
See also stackoverflow.com/questions/3202763/… and stackoverflow.com/questions/28409134/…
– Risadinha
Mar 7 at 14:06
add a comment |
Could there be a mismatch betweennumeric
and the floats that you are passing in? Check whether you get the same error with decimals, e.g.from decimal import Decimal; c.callproc('GetAllNotes', (Decimal('51.5'), Decimal('0.0')))
– Alasdair
Mar 7 at 11:59
1
@Alasdair Yes. I get the same error. And when I set float into the function, I get the same error.
– xomem
Mar 7 at 12:13
See also stackoverflow.com/questions/3202763/… and stackoverflow.com/questions/28409134/…
– Risadinha
Mar 7 at 14:06
Could there be a mismatch between
numeric
and the floats that you are passing in? Check whether you get the same error with decimals, e.g. from decimal import Decimal; c.callproc('GetAllNotes', (Decimal('51.5'), Decimal('0.0')))
– Alasdair
Mar 7 at 11:59
Could there be a mismatch between
numeric
and the floats that you are passing in? Check whether you get the same error with decimals, e.g. from decimal import Decimal; c.callproc('GetAllNotes', (Decimal('51.5'), Decimal('0.0')))
– Alasdair
Mar 7 at 11:59
1
1
@Alasdair Yes. I get the same error. And when I set float into the function, I get the same error.
– xomem
Mar 7 at 12:13
@Alasdair Yes. I get the same error. And when I set float into the function, I get the same error.
– xomem
Mar 7 at 12:13
See also stackoverflow.com/questions/3202763/… and stackoverflow.com/questions/28409134/…
– Risadinha
Mar 7 at 14:06
See also stackoverflow.com/questions/3202763/… and stackoverflow.com/questions/28409134/…
– Risadinha
Mar 7 at 14:06
add a comment |
1 Answer
1
active
oldest
votes
I think you have an issue with case sensitivity of function names in PostgreSQL.
Try this:
c.callproc('"GetAllNotes"', (float(longitude), float(latitude)))
Thank you very much.
– xomem
Mar 7 at 22:26
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55042972%2fwhy-doesnt-django-see-the-postgres-function%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I think you have an issue with case sensitivity of function names in PostgreSQL.
Try this:
c.callproc('"GetAllNotes"', (float(longitude), float(latitude)))
Thank you very much.
– xomem
Mar 7 at 22:26
add a comment |
I think you have an issue with case sensitivity of function names in PostgreSQL.
Try this:
c.callproc('"GetAllNotes"', (float(longitude), float(latitude)))
Thank you very much.
– xomem
Mar 7 at 22:26
add a comment |
I think you have an issue with case sensitivity of function names in PostgreSQL.
Try this:
c.callproc('"GetAllNotes"', (float(longitude), float(latitude)))
I think you have an issue with case sensitivity of function names in PostgreSQL.
Try this:
c.callproc('"GetAllNotes"', (float(longitude), float(latitude)))
answered Mar 7 at 12:51
Daniel HepperDaniel Hepper
17.9k54761
17.9k54761
Thank you very much.
– xomem
Mar 7 at 22:26
add a comment |
Thank you very much.
– xomem
Mar 7 at 22:26
Thank you very much.
– xomem
Mar 7 at 22:26
Thank you very much.
– xomem
Mar 7 at 22:26
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55042972%2fwhy-doesnt-django-see-the-postgres-function%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Could there be a mismatch between
numeric
and the floats that you are passing in? Check whether you get the same error with decimals, e.g.from decimal import Decimal; c.callproc('GetAllNotes', (Decimal('51.5'), Decimal('0.0')))
– Alasdair
Mar 7 at 11:59
1
@Alasdair Yes. I get the same error. And when I set float into the function, I get the same error.
– xomem
Mar 7 at 12:13
See also stackoverflow.com/questions/3202763/… and stackoverflow.com/questions/28409134/…
– Risadinha
Mar 7 at 14:06