0

Here is the python code with the query to the database

cursor.execute("""select count(distinct offering_name) as events
    ,count(learner) as learners 
    ,count(distinct learner) as unique_learner
    ,count(dropped) as dropped
    ,sum(trans_price) as trans_price
    from EMS_data where organization like 'eng%' and manager ='rakesh'""")

#result= cursor.fetchall()
for result in cursor:
    print result

the result will be like this

(367L, 7200L, 4543L, 7200L, 3216157.0)

but i want to like this

+--------+----------+----------------+---------+--------------------+
| events | learners | unique_learner | dropped | trans_price        |
+--------+----------+----------------+---------+--------------------+
|    378 |     8092 |           5204 |    8092 | 3197704.0799999996 |
+--------+----------+----------------+---------+--------------------+

how can do in this way... Please help

gcbenison
  • 11,723
  • 4
  • 44
  • 82
user2470026
  • 157
  • 1
  • 7
  • 5
    Check this out http://stackoverflow.com/questions/5909873/python-pretty-printing-ascii-tables – Maresh Jun 10 '13 at 14:03

1 Answers1

1

I don't understand your question, what's wrong? output format? It is a touple, you can access them using brackets [ ] and inside you put index, starting from 0.

print result[0] #prints 367

And then you can format it yourself.

FrUh
  • 545
  • 1
  • 4
  • 7