473,385 Members | 1,727 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

sum fonction in gadfly

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

Jun 24 '06 #1
8 1378
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
sc***********@acm.org
Jun 24 '06 #2
I haven't been keeping up. Is Gadfly still in development?

Jun 24 '06 #3
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 :
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
sc***********@acm.org


Jun 25 '06 #4
jean-jeanot wrote:
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
sc***********@acm.org
Jun 25 '06 #5

Robert Hicks wrote:
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.

Jun 29 '06 #6

aa***************@yahoo.com wrote:
Robert Hicks wrote:
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?


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

Jun 30 '06 #7

Robert Hicks wrote:
aa***************@yahoo.com wrote:
.... 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.


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"

Jun 30 '06 #8

aa***************@yahoo.com wrote:
Robert Hicks wrote:
aa***************@yahoo.com wrote:
.... 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.


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

Jun 30 '06 #9

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

Similar topics

1
by: Patrick W. Fraley | last post by:
Hi Everybuddy, I am having a little problem I can not find a solution for. I am trying to use the SQL-LIKE statement in gadfly. After googling around I found out that it is not supported, and...
4
by: Brian O. Bush | last post by:
A while ago, I recall hearing that Gadfly might be included into the python standard library. What happened? As I recall, the issue was the license. Brian
3
by: R.Marquez | last post by:
I tried installing gadfly 1.0 on Mandrake 9.2 and got the following: # python setup.py install running install error: invalid Python installation: unable to open...
1
by: Ian Pellew | last post by:
Hi all; Is there a Windows version of gadfly anywhere? All my searching gets me to Linux stuff (not that I have anything against Linux, rather I use Solaris) Regards Ian
0
by: Thomas | last post by:
Hi, i have a webserver with (approx.) the code below, but whatever i do the html code sent to the browser stays the same. The strangest is, if i insert a local variable in the class which is...
0
by: Tommy | last post by:
Hello I've got problems while using py2exe, because of a module I'm using : gadfly In fact, I had the same problem with Pmw, and the solution was to create a single file Pmw.py which contained...
3
by: Philippe Mesmeur | last post by:
J'ai eu une longue discussion hier au sujet des parametres de fonction const. La personne etait pour mettre "const" devant TOUS les parametres ne devant pas etre modifies. A mon avis, il faut...
3
by: niko | last post by:
Hello, while using gadfly, got an error that i don't understand. Code is as follow : cursor = connection.cursor() cursor.execute('select id_m from mots where nom_m = "%s"' % nom_m) id_m =...
6
by: Ralf Muschall | last post by:
Hello, I just tried the recent gadfly (from SF), using Python 2.4.2 (hand built, since my Suse 8.2 had only 2.2.2). The direct operation of gadfly works. After calling gfserver, I get (in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.