Calling a Postgres Function using CGI written in Python

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fuzzydave

    #1

    Calling a Postgres Function using CGI written in Python

    I need to call a function stored in Postgres which does a lot of the db
    and calculation work
    all the SQL queries are hardcoded in a file called cmi.py. What i need
    to do is too to call
    my function from postgres passing in my product_code variable into it
    and returning the
    value from the query into a variable i can print to screen as part of a
    HTML page.

    I am sure its very easy but have never done anything in python as have
    none of the guys
    i work with making this a bit of a problem.

    Cheers Guys
    David

  • Colin Gillespie

    #2
    Re: Calling a Postgres Function using CGI written in Python

    A quick google for "Python CGI" gives you lots of links. But if you
    intend to do much in the way of cgi, then I would recommend the spyce
    framework,http://spyce.sourceforge.net/

    HTH

    Colin


    Fuzzydave wrote:[color=blue]
    > I need to call a function stored in Postgres which does a lot of the db
    > and calculation work
    > all the SQL queries are hardcoded in a file called cmi.py. What i need
    > to do is too to call
    > my function from postgres passing in my product_code variable into it
    > and returning the
    > value from the query into a variable i can print to screen as part of a
    > HTML page.
    >
    > I am sure its very easy but have never done anything in python as have
    > none of the guys
    > i work with making this a bit of a problem.
    >
    > Cheers Guys
    > David
    >[/color]

    Comment

    • Fuzzydave

      #3
      Re: Calling a Postgres Function using CGI written in Python

      I did do a google search i have looking through the one python book i
      have
      and there are plenty of references for how to write a function in
      Python but
      not as many on how to call a function stored in postgres using python I
      have
      tried the conn.execute(cm i_grn_cost(prod uctCode)) and also the
      conn.callproc(c mi_grn_cost(pro ductCode)) commands where conn is the
      connection object and cmi_grn_cost() is the the function getting called
      from
      Postgres and productCode is the variable to passed.

      Comment

      • Fuzzydave

        #4
        Re: Calling a Postgres Function using CGI written in Python

        cheers :)

        thats what i wanted to know :)

        David

        Comment

        Working...