egbert wrote:
Yes, I know that this is off-topic, but I feel justified by sqlite3
being a builtin.
The default ON CONFLICT algorithm in SQLite is ABORT.
The SQLite documentation ("ON CONFLICT clause") says that when
a constraint violation occurs under ABORT, no rollback is executed,
so changes from prior commands within the same transaction are
preserved.
Isn't this a strange choice for a default ?
No, it's just like every other database error - the command fails but
the connection is left untouched.
After all, you expect that either all changes within a transaction
are preserved, or that nothing at all is preserved.
Sure, the successful ones ;-)
The Python Library Reference on sqlite3 says in paragraph 13.13.5
that I should not use the ROLLBACK conflict algorithm in my sql.
Instead I have to catch the IntegrityError and call the rollback method.
FWIW, this restriction is not any longer true in Python 2.6 and 3.0 btw.
You can now safely use "ON CONFLICT ROLBLACK" with the sqlite3 module.
Does that mean that I have to wrap all multi-command transactions
in a try-except if I don't like the default ABORT choice ?
Well, you have to do that *always* anyways if you want your app to
behave correctly. Typical usage of the DB-API looks like this:
cur = con.cursor()
try:
cur.execute(... )
cur.execute(... )
cur.execute(... )
con.commit()
except <DB-API-MODULE>.Databas eError:
con.rollback()
With the sqlite3 module, there's a shortcut:
from __future__ import with_statement
with con:
cur.execute(... )
cur.execute(... )
cur.execute(... )
which does exactly the same as the code above.
-- Gerhard 0 1469 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Pierre Quentel |
last post by:
I want to store strings in a sqlite database, but my strings may contain
null bytes and sqlite can't handle this. What is the best way to solve the
problem (the fastest in execution time and / or the one that produces the
least additional bytes) : base64, or is there a better solution ?
Thanks,
Pierre
|
by: stan k. |
last post by:
First of all i'm on a win32 platform using java. I also have mysql
installed. My question isabout benchmarks and multiple inserts &
selects
SQLITE: http://www.sqlite.org/
HSQL: http://hsqldb.sourceforge.net
I current have a mysql database of approx. 80mb.
Each day I Insert approx .5mb of new records into this table,
and I might also run mutiple Update, Delete, and Select queries as
well.
I'm trying to get an idea of how fast a sql...
|
by: Christian Stooker |
last post by:
Part one:
======
Hi !
I want to use SQLite database like the FireBird database: with big
isolation level.
What's that meaning ?
I have an application that periodically check some input directory,
|
by: ricardo.turpino |
last post by:
Hi,
I've installed Mac Python 2.5. I'm running Mac OS X 10.4.10 on a
Macbook 1.83GHz. I though that the python sqlite library was
installed by default as part of Mac Python 2.5, however, I still have
a problem.
Sqlite does not appear to be my system:
Traceback (most recent call last):
|
by: mikhail.savitsky |
last post by:
Hi,
Official Python distro is very stable, with release cycle of around 1
year. However, to include the new version of SQLite, which has a much
shorter release cycle, one has to rebuild the main Python distribution
(to compile with the new SQLite headers) - this is from Python docs.
Therefore, inclusion of PySQLite in Python-2.5.1 distro effectively
shrinks the Python release cycle to that of SQLite. I would not have
minded, except that...
| |
by: Gilles Ganault |
last post by:
Hello
I need to compile PHP5 with SQLite statically and without PDO.
I don't need DB-independence, so it's fine using sqlite_*() functions
instead of PDO.
1. I've downloaded, compiled, and installed
sqlite.org/sqlite-3.5.4.tar.gz, and...
2. used "--with-sqlite --disable-pdo", but it fails.
|
by: Joe Goldthwaite |
last post by:
Thanks Guilherme. That helped. I guess I was thinking that pysqlite would
automatically come with some version of sqlite. The fact that it doesn't is
what was causing me to get the strange results.
I downloaded the Windows version of the SQLite3.dll. I didn't know where to
put it so I first put it in its own directory and tried to register it.
That didn't work so I just moved it to the pysqlite directory in
site-packages. That did...
|
by: egbert |
last post by:
Yes, I know that this is off-topic, but I feel justified by sqlite3
being a builtin.
The default ON CONFLICT algorithm in SQLite is ABORT.
The SQLite documentation ("ON CONFLICT clause") says that when
a constraint violation occurs under ABORT, no rollback is executed,
so changes from prior commands within the same transaction are
preserved.
Isn't this a strange choice for a default ?
After all, you expect that either all changes...
|
by: timotoole |
last post by:
Hi all,
On a (sun) webserver that I use, there is python 2.5.1 installed. I'd
like to use sqlite3 with this, however sqlite3 is not installed on the
webserver. If I were able to compile sqlite using a sun machine (I
normally use linux machines) and place this in my lunix home account
would I be able to use python and sqlite?
Any thoughts? I know its a bit of a stretch ...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |