Question

I have the following class method that is meant to run database statements:

class CDatabaseModifier(object):
    def __init__(self, database):
        """ Constructor gets database
        """
        self._database = database
    def RunStatement(self, statement):
        """ Runs statement on database 
        """ 
        view = self._database.OpenView(statement)
        view.Execute(None)
        view.Close()
        self._database.Commit()

This works with INSERT INTO and DELETE statements, but for some reason I keep getting MSIError 2259 exceptions when I try to run the UPDATE statement with string as the parameter of SET. For example:

import msilib
db = msilib.OpenDatabase(r'C:\some\path\to\msi\bar.msi', msilib.MSIDBOPEN_DIRECT)
m = CDatabaseModifier(db)
m.RunStatement("UPDATE AppId SET ActivateAtStorage = 66 WHERE AppId = 'aaa'") # works OK
m.RunStatement("UPDATE AppId SET AppId = 'ccc' WHERE AppId = 'bbb'") # throws MSIError: 1: 2259 2
m.RunStatement("INSERT INTO AppId (AppId, RemoteServerName) VALUES ('foo', 'bar')") # works OK

More info: In the AppId table ActivateAtStorage column is short type, AppId and RemoteServerName columns are string type.

It says here that the 2259 error means that

Database: [2] Table(s) Update failed. Queries must adhere to the restricted Windows Installer SQL syntax.

Because the syntax of the UPDATE statement seams right, I have no idea what I'm doing wrong. Any help would be appreciated.

Was it helpful?

Solution

This site is magic: The minute you post a question you suddenly get the answer.

Anyway, I missed the part from here that clearly states that

UPDATE queries only work on nonprimary key columns.

which was exactly what I was trying to do (AppId is a primary key column). It had nothing to do with string types after all.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top