3

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 :)

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

mob The trigger gets called now , but when the trigger function gets executed , it says no such function: autocsvok , although the function exists

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.