sql - Trying to get the next value in sequence from a postgres DB, with django -


I have defined a sequence in my database that I want to use in my own dengue application. I thought I could use the raw SQL method specified in the DNS document here:. My plan was to execute the following SQL statement:

  choose the next ('winner')   

Where the winning sequence is I want to get the next value Are from Here is my code: django.db Transaction from import connection ..... cursor = connection.cursor () result = cursor.exicute ("select next ('winner')")

The result is not always of any kind, it seems very simple and simple, but I am not able to do this work. I have tried in the interactive console with the same result. If I look into the connection.queries object, I see it:

  {'time': '0.000', 'sql': "Choose the next ('winner')"}   

The generated SQL is valid. Any ideas?

I am using:

  • Django 1.1
  • Python 2.6
  • Postgrass 8.3
  • Psycopg2
  • Mac OSX

    cursor Always does not remove any returns.

    To get a value from the SQL statement, you should see the cursor.fetchone () (or fetchall () ).

    Note, though it does care that nothing has been done with Django, but the standard Python is SQL DB API.

Comments

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -