Mira yo hago con mysql, no sé si te servirá es solo un ejemplo:
Código Python:
Ver originaldef Conn (host = "localhost", database = "wasadu", username = "root", password = "1234"):
"""Connection to mysql
return cursor from the database"""
db = MySQLdb.connect (host,username,password,database)
cursor = db.cursor (cursorclass = MySQLdb.cursors.DictCursor)
return cursor
def ChannelTotal ():
"""Return the total of the price group by channel"""
date = CalculateFinishAndStartDates ()
finish = str (date[0])
start = str (date[1])
sql = """SELECT channel, SUM(price_sold) as total FROM users_tracking ut, auctions_bids ab
WHERE ut.bid_id = ab.auction_id AND ab.flag_buynow = 1 AND event_id = 8 AND ut.date BETWEEN '""" +start+"' AND '"+finish+"""'
GROUP by channel"""
cursor = Conn ()
cursor.execute (sql)
query = cursor.fetchall ()
list = []
for num in query:
channel = str (num['channel'])
total = str (num['total'])
list.append ([channel, total])