Trying to setup a button to write to a MySQL database.
Though the post don’t show it the first line “def” is the only one that is not tabbed.
def runAction(self, event):
"""
Method that will run whenever the selected event fires.
Arguments:
self: A reference to the component that is invoking this function.
event: An object that holds information about the selected event type
"""
DateV = system.date.now()
idV = 1
query = "UPDATE table SET date = ? WHERE id = ?"
args = [DateV, idV]
system.db.runPrepUpdate(query, args)
I then get:
Unable to run function “runAction(self, event)”, code could not be compiled.
Tab all of your actual code in by one tab.
Extension functions, such as runAction, act as if you were defining a Python function - so the top line (def runAction) is the only line that should actually be at the minimum indent level. Your code should look like this:
def runAction(self, event):
"""
some docstring here
"""
DateV = system.date.now()
# the rest of your code
and not like this:
def runAction(self, event):
"""
some docstring here
"""
DateV = system.date.now()
# the rest of your code