Re: Best practise of using custom sql with Stored Procedure

2009-03-14 Thread Alex Gaynor
On Sat, Mar 14, 2009 at 6:47 AM, timc3 wrote: > > > > So is that the list that you are talking about? > > > > I'm assuming those values corropond tot he fields on the model, any > reason > > you can't do: > > > > self.model(**cursor.fetchone()) > > > Just tried to do that but it

Re: Best practise of using custom sql with Stored Procedure

2009-03-14 Thread timc3
> > So is that the list that you are talking about? > > I'm assuming those values corropond tot he fields on the model, any reason > you can't do: > > self.model(**cursor.fetchone()) Just tried to do that but it seems to be returning things as a tuple so I get the error: ModelBase object

Re: Best practise of using custom sql with Stored Procedure

2009-03-10 Thread Alex Gaynor
On Tue, Mar 10, 2009 at 5:30 PM, timc3 wrote: > > Well I tried that: > >def get_perm(self, *args, **kwargs): >from django.db import connection >cursor = connection.cursor() >cursor.execute(""" >SELECT * FROM permfindernew(2, 132); >

Re: Best practise of using custom sql with Stored Procedure

2009-03-10 Thread timc3
Well I tried that: def get_perm(self, *args, **kwargs): from django.db import connection cursor = connection.cursor() cursor.execute(""" SELECT * FROM permfindernew(2, 132); """) result_list = [] for row in

Re: Best practise of using custom sql with Stored Procedure

2009-03-10 Thread Adam N
Tim, Here is how I do it with a different query. Using the fetchall() and getting it into a list works nicely. I know that there should be a better way to do this so that we're not making a list twice - but this works: query = """SELECT b.created_on, SUM(a.vote)

Best practise of using custom sql with Stored Procedure

2009-03-10 Thread timc3
Hi, I have built my models and so forth, but I have the need to check whether the user requesting an instance or set of instances from the database has permission to do so. For this I have a stored procedure (saved procedure) in the database that when I give it a user id, it then returns the