sum fonction in gadfly
Scott David Daniels
scott.daniels at acm.org
Sat Jun 24 08:04:24 EDT 2006
jean-jeanot wrote:
> After creating the table I create the variables with
> varAmount = StringVar()
Maybe you want to use DoubleVar or IntVar here?
> With a function
> def treatment ():
> requete = "insert into transactions ( date,amount,,....)
> values(......) "% (varDate.get(),
> varAmount.get
Or float(varAmount.get()) |
int(round(100 * float(varAmount.get()))) here
> cur.execute ("select sum(amount) from transactions").I get
> Sum.amout.transaction
> =================
> 100-10.5.......
>
> instead of 110.5
>
> It means that the select command does not add but concatenates the
> different amounts. Why ?
Sounds like you selected columns are strings, not numbers.
Remember '123.5' + '-23' is '123.5-23', while 123.5 + -23 is 100.5
You need the amount column of the transactions table in the gadfly
database to be a numeric type, not a string type.
--Scott David Daniels
scott.daniels at acm.org
More information about the Python-list
mailing list