473,699 Members | 2,433 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

May 3 '06 #1
3 2653
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:
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

May 3 '06 #2
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.

May 3 '06 #3
cheers :)

thats what i wanted to know :)

David

May 4 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4456
by: Marc Shapiro | last post by:
I am relatively new to python (I have used it on and off for a few small projects over the last few years) so I imagine that what I am trying to do has already been done, but practical experience, even if it is reinventing the wheel, is still useful, so... I am trying to write a module to handle drop down menus using curses (on linux). Curses seems to have a wrapper for the panels library, but not forms, or menus. I am not even sure...
1
3285
by: Steve | last post by:
I've searched throughout the python website and can't find an answer. My problem: After getting a BYTEA from a postgres database using Pygresql call: x = Db.query("SELECT seq FROM sequence \ WHERE version = \'NT_004350.16\' \ AND startloc = 1 \ AND endloc = 1120") y = x.getresult()
1
2671
by: Steve | last post by:
Hi, I have postgres 7.4.1 running on my server and I've been trying to find a good python-postgres interface module. I installed Pygres on another machine running Linux using a RPM release and it works. However, I need to do the same for an alpha server and I can't find source files for PyGres that would compile with 7.4.1 anywhere. Can someone please help me out? I need a good postgres python interface to work with. Cheers,
2
2562
by: Ksenia Marasanova | last post by:
Hi, I wonder if anyone on this list is using Python as Postgres procedural language. I can't find a place for it i my mind. How would a typical MVC web application benefit from it (besides performance)? I understand from the docs that Postgres 7.4 has PL/PythonU - unlimited functionality. It sounds like I have the whole Python available in Postgres. That means big parts of application logic can be moved to stored procedures, and dummy...
7
6659
by: Abdul-Wahid Paterson | last post by:
Hi, I have had a site working for the last 2 years and have had no problems until at the weekend I replace my database server with a newer one. The database migration went like a dream and I had the whole db changed over in 1 hour. Since the upgrade I have been getting the following error message sporadically.
10
2367
by: Hank | last post by:
We have just recently migrated the data from our Access 2000 backend to Postgres. All forms and reports seem to run correctly but, in many cases, very slowly. We do not want to switch over until we can speed things up. We would like to start implementing Stored Procedures so we can do Server-Side processing. Can anyone recommend a book that would help us learn how to use sprocs or pass-through queries? I apologize if my terminology...
7
13003
by: Pankaj | last post by:
The module which i am creating is like Part A: 1. It does some processing by using python code. 2. The result of this python code execution is written to a text file. ] Part B: 1. I read a text file which is outputted by above python script in a C++ program
0
2702
by: NM | last post by:
Hello, I've got a problem inserting binary objects into the postgres database. I have binary objects (e.g. images or smth else) of any size which I want to insert into the database. Funny is it works for files larger than 8000 Bytes. If a file is less than 1000 Bytes I get the following message: Error message: --invalid input syntax for type oid: "\074\077......";
4
5674
by: Alchemist | last post by:
I am using Python 2.4 and Postgresql 8.2 database server. On the database I have created a stored function, example, CREATE OR REPLACE FUNCTION calculateaverage() I created a new python script and would like to call my database stored function. How can I call a database stored function/procedure in python?
0
8687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8615
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9034
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8883
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7750
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5874
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3057
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2347
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.