[Tutor] sqlite3 format data from tables

David david at abbottdavid.com
Sat May 23 18:48:02 CEST 2009


David wrote:
> I have a budget program I am using to learn from.
> http://linuxcrazy.pastebin.com/f3b301daf
> 
> I can not figure out how to get the transaction details to return so 
> that it looks nice. It returns like this now.
> 
> Your transaction History is: [(1, u'Food', -100), (2, u'Deposit', -200), 
> (3, u'Deposit', 500), (4, u'Python Book', -50)]
> 
> Here is how it gets to that point;
> 
> def get_transactions(self):
>     ct=self.connection.cursor()
>     ct.execute("select * from transact;")
>     return ct.fetchall()
> 
> def report_transactions(self):
>     return self.database.get_transactions()
> 
> def display_transactions(self):
>     print "Your transaction History is:",self.bl.report_transactions()
> 
> self.menu[5]=("Transaction History",self.display_transactions)
> 
> Can I use the numbers 1,2,3,4 as a way to return the history?
> 
> Thanks, I hope I explained it correctly :)
> -david
Ok this seems to work OK;
     def display_transactions(self):
         transactions = self.bl.report_transactions()
         for data in transactions:
             print "Transaction History: ", data[-2], data[-1]


-- 
Powered by Gentoo GNU/Linux
http://linuxcrazy.com


More information about the Tutor mailing list