sum fonction in gadfly

J

jean-jeanot

I am writing a prototype program whose aim is to collect bookkeeping
transactions in a Database ( Gadfly).
After creating the table I create the variables with
varAmount = StringVar()
I then create labels in Tkinter to ease the input of data.
With a function
def treatment ():
requete = "insert into transactions ( date,amount,,....)
values(......) "% (varDate.get(),
varAmount.get
I transfer data from the labels in Tkinter into the Database at the end
of the program
with a button named "End" . I print the Database with print cur.pp().
No problem up to now but then I try to use a select command:
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 ?

Many thanks if you can help me.

Jean Moser
 
S

Scott David Daniels

jean-jeanot said:
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
(e-mail address removed)
 
J

jean-jeanot

Thank you for your help. I have changed StringVar in IntVar and it
works! I didn't know that IntVar (as StringVa) were Tkinter Widget
variables! (It is important to read the doc!) I made another mistake
in the value definition. I'have changed '%s' in %d and it goes
perfectly well.
It could be useful for me to change of DB ? Which one ? Postgresql or
another ?

Jean Moser

Scott David Daniels a écrit :
 
S

Scott David Daniels

jean-jeanot said:
Thank you for your help.
You're welcome.
It could be useful for me to change of DB ? Which one ? Postgresql or
another ?
Well, if gadfly is serving you well, you might as well stay with it.
Python 2.5 comes with sqlite3, which might well be a nice small step.
I find Postgresql to be a real solid DB, and a company I've been talking
with likes MySQL -- which finally has transactions (one of my personal
requirements before I'll call a DBMS "real").

Really, you should decide what you want the DBMS to do, and try to get
those requirements out; you'll get better advice.

--Scott David Daniels
(e-mail address removed)
 
A

aaronwmail-usenet

Robert said:
I haven't been keeping up. Is Gadfly still in development?

I always find this question a little
irritating -- gadfly is perfect the
way it is :). If it ain't broke don't
fix it. At least until the python guys
make another non-backwards-compatible
change that makes a patch necessary
(speaking of things that irritate me...).

Seriously, there are a few problems
that could be fixed that I can
think of, but mostly it works for what
it is -- why are people so concerned
that it's not changing?

-- Aaron Watters
http://gadfly.sourceforge.net/ --perfect already
http://xsdb.sourceforge.net/ --getting there

===
You'd be paranoid too if everyone was out to get you.
 
R

Robert Hicks

I always find this question a little
irritating -- gadfly is perfect the
way it is :). If it ain't broke don't
fix it. At least until the python guys
make another non-backwards-compatible
change that makes a patch necessary
(speaking of things that irritate me...).

Seriously, there are a few problems
that could be fixed that I can
think of, but mostly it works for what
it is -- why are people so concerned
that it's not changing?

I didn't mean to be irritating and I wasn't concerned about it not
changing but I could probably have stated the question a little better.
For some reason I thought it was a dead project so maybe "still being
maintained" would be a better statement. I dunno.

Robert
 
A

aaronwmail-usenet

Robert said:
I didn't mean to be irritating and I wasn't concerned about it not
changing but I could probably have stated the question a little better.
For some reason I thought it was a dead project so maybe "still being
maintained" would be a better statement. I dunno.

You're not the only one. Why do I keep seeing "gadfly...dead"
in the same sentence?

What if it doesn't need maintenance? Does that make it dead?
No offense to you personally, you are just repeating what
everyone else has been saying for years for reasons that
totally escape me. Several times people have suggested that
gadfly be added to the python standard library and then the
question comes up... who will maintain it? And I answer I'll
maintain it if anyone finds serious problems with it and then
a few months later I hear that it was decided that gadfly was
a dead project. This has been going on since about '97.
It's irritating and tiresome. Sorry, I'm grumpy today.

-- Aaron Watters

===
my mazarati goes 185
I lost my license
now I don't drive -- from "Life's been good"
 
R

Robert Hicks

You're not the only one. Why do I keep seeing "gadfly...dead"
in the same sentence?

What if it doesn't need maintenance? Does that make it dead?
No offense to you personally, you are just repeating what
everyone else has been saying for years for reasons that
totally escape me. Several times people have suggested that
gadfly be added to the python standard library and then the
question comes up... who will maintain it? And I answer I'll
maintain it if anyone finds serious problems with it and then
a few months later I hear that it was decided that gadfly was
a dead project. This has been going on since about '97.
It's irritating and tiresome. Sorry, I'm grumpy today.
Hey, that is okay. I know now never to ask that question. : D

Robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,078
Latest member
MakersCBDBlood

Latest Threads

Top