Reputation: 51
I'm trying to include a custom function inside a trigger clause in sqlite using python , I'm able to call the custom function when i just call the custom function , however i'm trying to include the custom function inside a trigger clause
This is my custom function creation
self.conn.create_function("autocsvok", 1, self.syslog_autocsv)
This is my callback python function
def syslog_autocsv(self,value):
print value
I'm able to call the callback function on
sql2='select autocsvok("ss")'
self.cur.execute(sql2)
This gives me output
ss
However , Now I try to include the custom function inside a trigger clause
sql3='''CREATE TRIGGER liiasssaa BEFORE INSERT ON syslog BEGIN
select autocsvok("55")
END'''
self.cur.execute(sql3)
print self.cur.fetchone()[0]
This gives me the following error
File "syslog.py", line 105, in syslog_createfunction
self.cur.execute(sql1)
sqlite3.OperationalError: near "END": syntax error
Kindly Help me :)
Upvotes: 3
Views: 992
Reputation: 1423
See the section of grammar between BEGIN
and END
https://www.sqlite.org/lang_createtrigger.html
The expression must be terminated with a semicolon. Your trigger's select
is not terminated by a semicolon.
Upvotes: 3