Re: [ceodbc-users] ceodbc and running stored procedures?
Brought to you by:
atuining
From: Lukasz S. <szy...@gm...> - 2010-07-19 19:36:40
|
On Mon, Jul 19, 2010 at 1:59 PM, Lukasz Szybalski <szy...@gm...> wrote: > On Mon, Jul 19, 2010 at 12:29 PM, Anthony Tuininga > <ant...@gm...> wrote: >> On Mon, Jul 19, 2010 at 11:09 AM, Lukasz Szybalski <szy...@gm...> wrote: >>> On Mon, Jul 19, 2010 at 10:57 AM, Anthony Tuininga >>> <ant...@gm...> wrote: >>>> Hi, use the DB API method callproc instead of trying to execute the >>>> SQL directly. >>>> >>>> cursor.callproc("assp_Report_DailyTransactions", '20100701', '20100715') >>> >>> How can I specify the parameters? Let say I have 5 of them, >>> >>> Company, State, start_date, end_date, other. >>> >>> The company,state auto default to "All" , so I just have to specify >>> the start and end date. If I pass >>> cursor.callproc("assp_Report_DailyTransactions", '20100701', >>> '20100715') how do I know the 20100701 is a start date and not the >>> "company name"? >> >> callproc() only supports positional parameters so you have to specify >> all of them up to the last parameter you want to pass. I'm not aware >> of any standard method with ODBC to pass keyword parameters. >> >> If you want to call the SQL directly, then you will have to do >> something similar to what I am doing with callproc() >> >> CALL MyProcedure(?, ?, ?) >> >> You could try >> >> CALL MyProcedure(start_date = ?, end_date = ?) > > Sorry. How do I call it again? > > cursor = connection.cursor() > cursor.execute('call assp_ReportDailyTransactions(start_date=?, > end_date=?)') ???? > If you could guide me here. This kind of works, but I'm not able to add another parameter. a=cursor.execute("assp_ReportDailyTransactions @start_date='07/14/2010'") >>> l=a.fetchall() >>> len(l) 4 and: a=cursor.execute("assp_ReportDailyTransactions @start_date='07/14/2010', @end_date='07/18/2010'") >>> l=a.fetchall() >>> len(l) 3 Is this how I should be running it? Not pythonic looking, but it does execute.? Thanks, Lucas |