Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4112390
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:11:22+00:00 2026-05-20T22:11:22+00:00

I have a sequence defined in my database that I want to use in

  • 0

I have a sequence defined in my database that I want to use in my django application. I assumed I could use the raw sql method specified in the django documentation here: http://docs.djangoproject.com/en/1.1/topics/db/sql/. My plan was to execute the following SQL statment:

select nextval('winner')

where winner is the sequence I want to get the next value from. Here is my code:

from django.db import connection, transaction

.....

cursor = connection.cursor()

result = cursor.execute("select nextval('winner')")

The result is always a NoneType object. This seems pretty simple and straightforward, but I haven’t been able to make this work. I’ve tried it in the interactive console with the same results. If I look in the connection.queries object, i see this:

{'time': '0.000', 'sql': "select nextval('winner')"}

The sql generated is valid. Any ideas?

I’m using:

  • Django 1.1
  • Python 2.6
  • Postgres 8.3
  • Psycopg2
  • Mac OSX
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T22:11:23+00:00Added an answer on May 20, 2026 at 10:11 pm

    cursor.execute always returns None.

    To get the value from the SQL statement, you have to use cursor.fetchone() (or fetchall()).

    See the documentation, although note that this doesn’t actually have anything to do with Django, but is the standard Python SQL DB API.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a sequence of SQL calls, which I want to use to detect
I have a number of tables that use the trigger/sequence column to simulate auto_increment
I have several elements defined in my XSD file that I use as references
I use H2 Database for my unit tests. In my application, I have an
If I have sequence of sequences (maybe a list of tuples) I can use
I have one hibernate sequence, that generates all sequence-numbers in my app. When I
I have a table that records a sequence of actions with a field that
I have two models in my Django application, for the purposes of storing search
I'm writing a PHP-based web application that should work with multiple database systems. The
I have an entity defined with a sequence-generated primary key: @Id @GeneratedValue(strategy = GenerationType.SEQUENCE,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.