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?













0















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'")
r = c.fetchone()
- then the 'GetAllNotes' function will be listed










share|improve this question
























  • 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
















0















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'")
r = c.fetchone()
- then the 'GetAllNotes' function will be listed










share|improve this question
























  • 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














0












0








0








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'")
r = c.fetchone()
- then the 'GetAllNotes' function will be listed










share|improve this question
















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'")
r = c.fetchone()
- then the 'GetAllNotes' function will be listed







python django psycopg2






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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


















  • 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

















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













1 Answer
1






active

oldest

votes


















1














I think you have an issue with case sensitivity of function names in PostgreSQL.



Try this:



c.callproc('"GetAllNotes"', (float(longitude), float(latitude)))





share|improve this answer























  • Thank you very much.

    – xomem
    Mar 7 at 22:26










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
);



);













draft saved

draft discarded


















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









1














I think you have an issue with case sensitivity of function names in PostgreSQL.



Try this:



c.callproc('"GetAllNotes"', (float(longitude), float(latitude)))





share|improve this answer























  • Thank you very much.

    – xomem
    Mar 7 at 22:26















1














I think you have an issue with case sensitivity of function names in PostgreSQL.



Try this:



c.callproc('"GetAllNotes"', (float(longitude), float(latitude)))





share|improve this answer























  • Thank you very much.

    – xomem
    Mar 7 at 22:26













1












1








1







I think you have an issue with case sensitivity of function names in PostgreSQL.



Try this:



c.callproc('"GetAllNotes"', (float(longitude), float(latitude)))





share|improve this answer













I think you have an issue with case sensitivity of function names in PostgreSQL.



Try this:



c.callproc('"GetAllNotes"', (float(longitude), float(latitude)))






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 7 at 12:51









Daniel HepperDaniel Hepper

17.9k54761




17.9k54761












  • 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





Thank you very much.

– xomem
Mar 7 at 22:26



















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved