avatar
Tips for Optimizing Digital Marketing Efforts

Guest 140 17th Jan, 2025

import sqlite3
con = sqlite3.connect('testdb.db')
cur = con.cursor()
ordersSQL = """
            CREATE TABLE R (
                A int,
                B int,
                C int
            ) """
cur.execute(ordersSQL)
cur = con.cursor()
# trigger insert
cur.execute ("""create trigger aft_insert after insert on R
begin
select case
when ( select count(distinct B)
from R
where A = new.A ) > 1 then
raise (abort, 'Insert violate A
B')

end;
end; """ )

#trigger update
cur.execute ( """create trigger alt_update after update on R
begin
select case
when ( select count(distinct B)
from R
where A = new.A ) > 1 then
raise (abort, 'Update violate A
B')

end;
end; """ )

odersSQL = """
            INSERT INTO R(A,B,C) VALUES(?,?,?);
         """
odersSQL = """
            UPDATE R SET A = ?, B = ?, C = ?
            WHERE A = 1
        """
#cur.execute(odersSQL,(2,2,2))
result = cur.execute("select * from R")
for i in result:
    print(i)
Markup
Description

No description

To share this paste please copy this url and send to your friends
RAW Paste Data