Nested Looping SQL Querys

2006-09-20 Thread Fuzzydave
I am back developing futher our Python/CGI based web application run by a Postgres DB and as per usual I am having some issues. It Involves a lot of Legacy code. All the actual SQL Querys are stored in the .py files and run in the .cgi files. I have the problem that I need to construct a row from

round not rounding to 0 places

2006-08-16 Thread Fuzzydave
I have been using a round command in a few places to round a value to zero decimal places using the following format, round('+value+', 0) but this consistantly returns the rounded result of the value to one decimal place with a zero EG: 4.97 is returned as 5.0 when i want it returned as 5,

Re: round not rounding to 0 places

2006-08-16 Thread Fuzzydave
Sybren Stuvel wrote: round returns a float. Use int(round('+value+', 0)) to get an integer. Sybren ahh of course it does, slaps own forehead sorted thanks :) David P -- http://mail.python.org/mailman/listinfo/python-list

Python checking for None/Null values

2006-08-11 Thread Fuzzydave
Okay, I have been handed a python project and working through it I have had to add a report. I am returning 10 variables the results of an SQL Query and as usual the number of results vary from 1 result to 10 results so I implemented a check to see if the array item was empty or not. The code is

Re: Python checking for None/Null values

2006-08-11 Thread Fuzzydave
`historyRep` seems to be shorter than you think it is. Try printing it too see what it actually contains. Ciao, Marc 'BlackJack' Rintsch HistoryRep is an array value so historyRep[0] to [7] all have values in them but historyRep[8] and [9] do not as the query does not always return a

Re: Python checking for None/Null values

2006-08-11 Thread Fuzzydave
Check with if history8 is not None. Won't help your problem, but it is a bit more pythonic code ;-) Sybren Actually i tried that as well when i was fooling around, atm i am less concenred with pythonic code and making it work in the first place. The entire program to be fair is a bit messy

Re: Python checking for None/Null values

2006-08-11 Thread Fuzzydave
Note: sometimes having a clean and readable program is better than having a running program that you can't read, because you can fix the the first one, and it can teach you something. Bye, bearophile Thanks for your help and suggestions i'll give them a shot. Unfortunatly when working with

Re: Python checking for None/Null values

2006-08-11 Thread Fuzzydave
[EMAIL PROTECTED] wrote: A way to solve your problem is to see how many elements the list contains with len(sequence) cheers after your post went of to try it and it worked first time thanks for being helpful and plesant :) Fuzzy -- http://mail.python.org/mailman/listinfo/python-list

Re: Calling a Postgres Function using CGI written in Python

2006-05-04 Thread Fuzzydave
cheers :) thats what i wanted to know :) David -- http://mail.python.org/mailman/listinfo/python-list

Calling a Postgres Function using CGI written in Python

2006-05-03 Thread Fuzzydave
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

Re: Calling a Postgres Function using CGI written in Python

2006-05-03 Thread Fuzzydave
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(cmi_grn_cost(productCode)) and also the