Re: how to get CURRVAL()

2008-09-20 Thread Daniel Roseman

On Sep 20, 6:05 am, Merrick <[EMAIL PROTECTED]> wrote:
> I have a function in my model where I need the next sequence id from
> postgresql so i can create an encoded value based off it. Any ideas on
> how to do this?

You can use the db.connection object for direct access to the
database. I don't use Postgres, but it would be something like this:

from django.db import connection

cursor = connection.cursor()
cursor.execute("SELECT curval('sequence');")
curval = cursor.fetchone()

There might even be a direct way of getting curval from the connection
object - look at the Python Postgres documentation.
--
DR.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



how to get CURRVAL()

2008-09-19 Thread Merrick

I have a function in my model where I need the next sequence id from
postgresql so i can create an encoded value based off it. Any ideas on
how to do this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---