[Tutor] formatting sql Was: Some help Please

bob gailer bgailer at gmail.com
Wed Feb 15 18:13:23 CET 2012


Welcome to python help. We are a few volunteers who donate time to assist.

To assist you better:
1 - provide a meaningful subject line - such as "formatting sql"
2 - tell us what OS and Python version you are using.
3 - what is your prior Python experience?


On 2/15/2012 9:17 AM, JOSEPH MARTIN MPALAKA wrote:
> take an example of updating Bank Accounts,
> gaving the following table:
>
> acc_id		acc_name	    standing_Balance
> mn0001		computer	     20000
>
> my problem is how can i credit the standing balance from user data,as
> in making a deposit onto the computer account, using the code below:-
>
>
>
> import MySQLdb as mdb
> import sys
>
> con = mdb.connect('localhost', 'joseph', 'jmm20600', 'savings');
>
> dep = input('Enter Amount: ')
>
>              cur.execute("UPDATE accounts SET Standing_Amount =
> (Standing_Amount + dep) WHERE Acc_ID = 'MN0001'")
In you table the acc_id is 'mn0001'
In your sql Acc_ID = 'MN0001'
Why the difference in case?
Why the () around Standing_Amount + dep?

>
> 	conn.commit()
>
> HOw do i format "dep" in order to be added onto the standing_Amount,to
> make an increment?
>
> Please, is it the same thing with the withdrawing format, in case i
> want to decrement the account as in withdrawing??
>
>
> joseph
>
>
>
>
>
>
>
>
>


-- 
Bob Gailer
919-636-4239
Chapel Hill NC



More information about the Tutor mailing list