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

  • SEARCH
  • Home
  • 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 597041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:14:14+00:00 2026-05-13T16:14:14+00:00

def rollback_savepoint(self): try: self.db.execute(rollback to savepoint pt;) except: print roll back to save point

  • 0
def rollback_savepoint(self):
    try:
        self.db.execute("rollback to savepoint pt;")
    except:
        print "roll back to save point failed"
    else:
        print "Roll back to save point. Done"

In above code snippet , It says “roll back to save point failed”.
What went wrong?

EDIT:
I changed the code as shown below and getting error messages

self.db.execute("savepoint pt;")
print "Save point created"

self.cursor.execute("insert into STK values(33)")
self.db.execute("rollback to savepoint pt;")

error

Save point created
Traceback (most recent call last):
  File "open_db.py", line 77, in <module>
    obj1.save_point()
  File "open_db.py", line 63, in save_point
    self.db.execute("rollback to savepoint pt;")
sqlite3.OperationalError: no such savepoint: pt
  • 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-13T16:14:14+00:00Added an answer on May 13, 2026 at 4:14 pm

    Don’t ever catch exceptions you aren’t handling. Let it raise, so you can have useful error messages and tracebacks.

    Example:

    >>> c.execute('rollback to savepoint pt;')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    sqlite3.OperationalError: no such savepoint: pt
    

    From the traceback I can know the error is that there’s no pt savepoint. I can’t know what’s wrong with yours because you’re hiding the very information that can help you most. Catching all errors and printing some “Failed” message is dumb – the traceback is much more useful and explains the problem better.


    EDIT:
    Your code wasn’t exactly a easy-to-run testcase, but by reading it I was able to write some code myself to reproduce the issue. I can’t explain exactly what is going on yet, but I found a way to make it work – related to how sqlite3 module deals with transactions.

    Here’s my full, runnable example:

    import sqlite3
    from tempfile import NamedTemporaryFile as NF
    import os
    
    f = NF(suffix='.db', delete=False).name
    
    db = sqlite3.connect(f)
    
    try:
        db.execute('CREATE TABLE foo (id INTEGER PRIMARY KEY, data VARCHAR)')
        db.isolation_level = None
    
        db.execute('INSERT INTO foo (data) values (?)', ('hello',))
        db.execute('INSERT INTO foo (data) values (?)', ('world',))
    
        db.execute("savepoint pt;")
        db.execute('INSERT INTO foo (data) values (?)', ('bah',))
        db.execute('INSERT INTO foo (data) values (?)', ('goodbye world',))
        db.execute("rollback to savepoint pt;")
    
        db.execute('INSERT INTO foo (data) values (?)', ('peace',))
    
        assert list(db.execute('select * from foo')) == [(1, 'hello'),
                                                         (2, 'world'),
                                                         (3, 'peace')]
    finally:
        db.close()
        os.remove(f)
    

    The line that makes it work is db.isolation_level = None. If you comment it out, it breaks just like your error. I’ve tried using all the documented values “DEFERRED”, “IMMEDIATE” and “EXCLUSIVE”, all ended in error.

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

Sidebar

Related Questions

def download_if_dne(href, filename): if os.path.isfile(filename): # print 'already downloaded:', href return False else: if
@transection.commit_on_success def recordIt(...) try: .... recordable = firstDataInsertionFunction(...) if recordable: myRec = SecondDataInsertion(.....) except:
def exec_command(self, command, bufsize=-1): #print Executing Command: +command chan = self._transport.open_session() chan.exec_command(command) stdin =
How do you roll back a failed rails migration? I would expect that rake
def __init__(self, maximum, start=0, step=1): Sets the maximum, start, and step try: self.maximum =
The error shows this code can not rollback: class AddCountToTag < ActiveRecord::Migration def change
In ActiveRecord model after_save callback I need to ROLLBACK transaction and return false. def
def self.jq_column_models COLUMN_NAME.collect {|x| {:name => x.to_s, :width => 80, :format => 'integer' if
def myFunc( a, b ): def innerFunc( c ): print c innerFunc( 2 )
def update @album = Album.find(params[:id]) if @album.update_attributes(params[:album]) redirect_to(:action=>'list') else render(:action=>'edit') end end A Rails

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.