%s shortcut?

james_027 cai.haibin at gmail.com
Wed Sep 26 04:55:17 CEST 2007


hi i have something like this

cursor.execute("""
            select c.name,
                (select from ap_invoice i where Month(i.date) = 1 and
Year(i.date) = %s and i.customer_id = c.id and i.status != 'CAN') jan,
                (select from ap_invoice i where Month(i.date) = 2 and
Year(i.date) = %s and i.customer_id = c.id and i.status != 'CAN') feb,
                (select from ap_invoice i where Month(i.date) = 3 and
Year(i.date) = %s and i.customer_id = c.id and i.status != 'CAN') mar
            from ap_customer c
            order by %s""",
            [year, order_by])

what I could like to happen is ... since the first three %s points to
the same year variable, how do I let python know it without doing
[year ,year, year, order_by] ... This should be 12 I just cut it down

Thanks
james




More information about the Python-list mailing list