Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.

My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/python2.6
# -*- coding: utf-8 -*-

import os, sys, getpass, MySQLdb

# connect to the MySQL server and select the databases
dbhost = 'localhost'
dbuser = 'user'
from_db = 'boutique'

if os.environ.has_key('MYSQL_PASSWD'):
	dbpasswd = os.environ['MYSQL_PASSWD']
else:
	dbpasswd = getpass.getpass("Enter MySQL password: ")
try:
	org = MySQLdb.connect (host = dbhost, user = dbuser, passwd = dbpasswd)	

except MySQLdb.Error, e:
	print "Error %d: %s" % (e.args[0], e.args[1])
	sys.exit (1)

main = org.cursor()

# select the database
main.execute('USE %s' % from_db)
from_date = '2011-06-23'
to_date = '2011-06-24'
daily_total_orders = "SELECT COUNT(DISTINCT o.id_order) as orders, SUM(o.total_paid / c.conversion_rate) as ttc, \
                ((SUM(o.total_products) - SUM(o.total_discounts)) / c.conversion_rate) as ht \
                    FROM ps_orders o INNER JOIN ps_currency c ON o.id_currency = c.id_currency \
                    WHERE o.valid = 1 AND o.invoice_date BETWEEN (%s) AND (%s)"


main.execute(daily_total_orders, (from_date, to_date))

results = main.fetchall()
try:	
	for row in results:
		print row, from_date
except MySQLdb.Error, e:
	print "Error %s" % e
	sys.exit (1)