import sqlite3
# connect to memory-only database for testing
con = sqlite3.connect('')
cur = con.cursor()
# create the table
cur.execute('''
CREATE TABLE CorpWalletJournal (
date INT, refID INT, refTypeID INT, ownerName1 TEXT,
ownerID1 INT, ownerName2 TEXT, ownerID2 INT, argName1 TEXT,
argID1 ID, amount INT, balance INT, reason TEXT, accountKey INT,
UNIQUE (ownerID1, ownerID2, accountKey, argID1)
);
''')
con.commit()
insert_sql = '''INSERT INTO CorpWalletJournal
(date, refID, refTypeID, ownerName1, ownerID1, ownerName2, ownerID2,
argName1, argID1, amount, balance, reason, accountKey)
VALUES
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'''
## create 5 rows changing only argID1 - it works:
for argid in xrange(5):
cur.execute(insert_sql, (1, 1, 1, 'a', 1, 'a', 1, 'a', argid, 1, 1, 'a', 1))
con.commit()
# now try to insert a row that is already there:
cur.execute(insert_sql, (1, 1, 1, 'a', 1, 'a', 1, 'a', 0, 1, 1, 'a', 1))