Re: [Tutor] set the BETWEEN range in the SQL query using the python datetime function

2011-06-24 Thread Peter Otten
Norman Khine wrote:

 hello, i have this code http://pastie.org/2112997
 
 but i am not sure how to make the date range so that i get a list
 based on the daily totals not the results i am now getting:
 
 (2L, Decimal('173.958344'), Decimal('159.966349')) 2011-06-23 00:00:00
 2011-06-23 23:59:59
 (2L, Decimal('173.958344'), Decimal('159.966349')) 2011-06-22 00:00:00
 2011-06-23 23:59:59

What should the result look like? Can you give a simplified example with 
input and output data?

 the problem is that i am unsure how best to set the BETWEEN range in
 the SQL query using the python datetime function.

My guess is that you can move more of the problem from Python into SQL if 
you add a GROUP BY clause.


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] set the BETWEEN range in the SQL query using the python datetime function

2011-06-24 Thread Norman Khine
thank you, it was simpler than what i was trying to do, here is the
revised version:

http://pastie.org/2115586

one thing i am getting an error is on like 103, in that if, i change
(http://pastie.org/2115615):

-plt.legend(('Income - GBP', 'Discounts', 'Google AdWords - GBP',
'Commission - %s GBP' % (total_commission)),
+plt.legend(('Income - GBP', 'Discounts', 'Google AdWords - %s GBP',
'Commission - %s GBP' % (total_adwords, total_commission)),
'upper right', shadow=True)

i get the following traceback:

Traceback (most recent call last):
  File commission.py, line 119, in module
plt.legend(('Income - GBP', 'Discounts', 'Google AdWords - %s
GBP', 'Commission - %s GBP' % (total_adwords, total_commission)),
TypeError: not all arguments converted during string formatting

what am i missing?

thanks

norman

On Fri, Jun 24, 2011 at 12:18 PM, Peter Otten __pete...@web.de wrote:
 Norman Khine wrote:

 hello, i have this code http://pastie.org/2112997

 but i am not sure how to make the date range so that i get a list
 based on the daily totals not the results i am now getting:

 (2L, Decimal('173.958344'), Decimal('159.966349')) 2011-06-23 00:00:00
 2011-06-23 23:59:59
 (2L, Decimal('173.958344'), Decimal('159.966349')) 2011-06-22 00:00:00
 2011-06-23 23:59:59

 What should the result look like? Can you give a simplified example with
 input and output data?

 the problem is that i am unsure how best to set the BETWEEN range in
 the SQL query using the python datetime function.

 My guess is that you can move more of the problem from Python into SQL if
 you add a GROUP BY clause.


 ___
 Tutor maillist  -  Tutor@python.org
 To unsubscribe or change subscription options:
 http://mail.python.org/mailman/listinfo/tutor




--
˙ʇı ɹoɟ ƃuıʎɐd ǝɹ,noʎ ʍou puɐ ǝɔıoɥɔ ɐ ʞooʇ ı ʇɐɥʇ sı 'ʇlnɔıɟɟıp sı ʇɐɥʍ
˙uʍop ǝpısdn p,uɹnʇ pןɹoʍ ǝɥʇ ǝǝs noʎ 'ʇuǝɯɐן sǝɯıʇ ǝɥʇ puɐ 'ʇuǝʇuoɔ
ǝq s,ʇǝן ʇǝʎ
% .join( [ {'*':'@','^':'.'}.get(c,None) or
chr(97+(ord(c)-83)%26) for c in ,adym,*)uzq^zqf ] )
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] set the BETWEEN range in the SQL query using the python datetime function

2011-06-24 Thread Peter Otten
Norman Khine wrote:

 thank you, it was simpler than what i was trying to do, here is the
 revised version:
 
 http://pastie.org/2115586
 
 one thing i am getting an error is on like 103, in that if, i change
 (http://pastie.org/2115615):
 
 -plt.legend(('Income - GBP', 'Discounts', 'Google AdWords - GBP',
 'Commission - %s GBP' % (total_commission)),
 +plt.legend(('Income - GBP', 'Discounts', 'Google AdWords - %s GBP',
 'Commission - %s GBP' % (total_adwords, total_commission)),
 'upper right', shadow=True)
 
 i get the following traceback:
 
 Traceback (most recent call last):
   File commission.py, line 119, in module
 plt.legend(('Income - GBP', 'Discounts', 'Google AdWords - %s
 GBP', 'Commission - %s GBP' % (total_adwords, total_commission)),
 TypeError: not all arguments converted during string formatting
 
 what am i missing?

'Commission - %s GBP' % (total_adwords, total_commission))

Two items in the tuple but only one '%s' in the format string. You probably 
wanted

... 'Google AdWords - %s GBP' % total_adwords, 'Commission - %s GBP' % 
total_commission ...

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] set the BETWEEN range in the SQL query using the python datetime function

2011-06-24 Thread Christian Witts

On 2011/06/24 01:19 PM, Norman Khine wrote:

thank you, it was simpler than what i was trying to do, here is the
revised version:

http://pastie.org/2115586

one thing i am getting an error is on like 103, in that if, i change
(http://pastie.org/2115615):

-plt.legend(('Income - GBP', 'Discounts', 'Google AdWords - GBP',
'Commission - %s GBP' % (total_commission)),
+plt.legend(('Income - GBP', 'Discounts', 'Google AdWords - %s GBP',
'Commission - %s GBP' % (total_adwords, total_commission)),
 'upper right', shadow=True)

i get the following traceback:

Traceback (most recent call last):
   File commission.py, line 119, inmodule
 plt.legend(('Income - GBP', 'Discounts', 'Google AdWords - %s
GBP', 'Commission - %s GBP' % (total_adwords, total_commission)),
TypeError: not all arguments converted during string formatting

what am i missing?

thanks

norman


You've got 'Google AdWords - %s GBP' with no arguments and 'Commission - 
%s GBP' with 2 arguments.


--

Christian Witts
Python Developer

//

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] set the BETWEEN range in the SQL query using the python datetime function

2011-06-24 Thread Norman Khine
On Fri, Jun 24, 2011 at 1:31 PM, Christian Witts cwi...@compuscan.co.za wrote:
 On 2011/06/24 01:19 PM, Norman Khine wrote:

 thank you, it was simpler than what i was trying to do, here is the
 revised version:

 http://pastie.org/2115586

 one thing i am getting an error is on like 103, in that if, i change
 (http://pastie.org/2115615):

 -plt.legend(('Income - GBP', 'Discounts', 'Google AdWords - GBP',
 'Commission - %s GBP' % (total_commission)),
 +plt.legend(('Income - GBP', 'Discounts', 'Google AdWords - %s GBP',
 'Commission - %s GBP' % (total_adwords, total_commission)),
 'upper right', shadow=True)

 i get the following traceback:

 Traceback (most recent call last):
   File commission.py, line 119, in module
 plt.legend(('Income - GBP', 'Discounts', 'Google AdWords - %s
 GBP', 'Commission - %s GBP' % (total_adwords, total_commission)),
 TypeError: not all arguments converted during string formatting

 what am i missing?

 thanks

 norman

 You've got 'Google AdWords - %s GBP' with no arguments and 'Commission - %s
 GBP' with 2 arguments.

thanks


 --

 Christian Witts
 Python Developer





-- 
˙ʇı ɹoɟ ƃuıʎɐd ǝɹ,noʎ ʍou puɐ ǝɔıoɥɔ ɐ ʞooʇ ı ʇɐɥʇ sı 'ʇlnɔıɟɟıp sı ʇɐɥʍ
˙uʍop ǝpısdn p,uɹnʇ pןɹoʍ ǝɥʇ ǝǝs noʎ 'ʇuǝɯɐן sǝɯıʇ ǝɥʇ puɐ 'ʇuǝʇuoɔ
ǝq s,ʇǝן ʇǝʎ
% .join( [ {'*':'@','^':'.'}.get(c,None) or
chr(97+(ord(c)-83)%26) for c in ,adym,*)uzq^zqf ] )
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] set the BETWEEN range in the SQL query using the python datetime function

2011-06-23 Thread Norman Khine
hello, i have this code http://pastie.org/2112997

but i am not sure how to make the date range so that i get a list
based on the daily totals not the results i am now getting:

(2L, Decimal('173.958344'), Decimal('159.966349')) 2011-06-23 00:00:00
2011-06-23 23:59:59
(2L, Decimal('173.958344'), Decimal('159.966349')) 2011-06-22 00:00:00
2011-06-23 23:59:59
(6L, Decimal('786.816548'), Decimal('744.840562')) 2011-06-21 00:00:00
2011-06-23 23:59:59
(12L, Decimal('1410.674749'), Decimal('1326.722775')) 2011-06-20
00:00:00 2011-06-23 23:59:59
(14L, Decimal('1577.628295'), Decimal('1476.683527')) 2011-06-19
00:00:00 2011-06-23 23:59:59
(15L, Decimal('1634.608277'), Decimal('1526.667511')) 2011-06-18
00:00:00 2011-06-23 23:59:59
(18L, Decimal('2015.542555'), Decimal('1886.613796')) 2011-06-17
00:00:00 2011-06-23 23:59:59
(21L, Decimal('2306.470462'), Decimal('2156.553710')) 2011-06-16
00:00:00 2011-06-23 23:59:59
(25L, Decimal('2574.386376'), Decimal('2396.485633')) 2011-06-15
00:00:00 2011-06-23 23:59:59
(27L, Decimal('2878.338279'), Decimal('2686.445540')) 2011-06-14
00:00:00 2011-06-23 23:59:59

the problem is that i am unsure how best to set the BETWEEN range in
the SQL query using the python datetime function.

cheers

norman

-- 
˙ʇı ɹoɟ ƃuıʎɐd ǝɹ,noʎ ʍou puɐ ǝɔıoɥɔ ɐ ʞooʇ ı ʇɐɥʇ sı 'ʇlnɔıɟɟıp sı ʇɐɥʍ
˙uʍop ǝpısdn p,uɹnʇ pןɹoʍ ǝɥʇ ǝǝs noʎ 'ʇuǝɯɐן sǝɯıʇ ǝɥʇ puɐ 'ʇuǝʇuoɔ
ǝq s,ʇǝן ʇǝʎ
% .join( [ {'*':'@','^':'.'}.get(c,None) or
chr(97+(ord(c)-83)%26) for c in ,adym,*)uzq^zqf ] )
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor