-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
msilib: can't close opened database #64685
Comments
In Python 2.7.6 can't find any way to close MSI database after finish working with it. import msilib
db = msilib.OpenDatabase('test.msi', msilib.MSIDBOPEN_TRANSACT)
view = db.OpenView("SELECT File, Component_, FileName FROM File")
view.Execute(None)
r1 = view.Fetch()
r1.SetString(3,"test.txt")
view.Modify(msilib.MSIMODIFY_UPDATE, r1)
view.Close()
db.Commit()
del db
db2 = msilib.OpenDatabase('test.msi', msilib.MSIDBOPEN_TRANSACT)
|
Sorry folks I can't try this myself as I'm not running 2.7 and I don't know how to create the test.msi file. |
This is still present in Python 3.5. There is no way to unlock the MSI file without killing the Python process first. |
Guessing the msiobj_close function in PC/_msi.c ought to be exposed. Patches welcome. |
I will prefix this by saying that I have not contributed to the Python source before and this patch is probably wrong, but here is my attempt at a fix. |
Thanks for the patch, 12345. Steve knows better, but I think the method should be named "Close" instead of "close" like _msi.View's Close method. Also, I couldn't apply your patch: $ hg imp http://bugs.python.org/file45971/Add_ability_to_close_MSI_database_.patch
applying http://bugs.python.org/file45971/Add_ability_to_close_MSI_database_.patch
unable to find '_msi.c' for patching
patching file _msi.c
2 out of 2 hunks FAILED -- saving rejects to file _msi.c.rej
abort: patch failed to apply You may want to read https://docs.python.org/devguide/patch.html for details about creating a patch. |
The method is now capitalized. Unfortunately, none of the methods are compliant with PEP formatting, but it's far too late to do anything about that. |
xoviat, would you like to send your patch as a pull request on GitHub? It would be nice to add a simple test that the new Close() works correctly. I can do that if you don't have time, thank you! Steve, can we apply this to bugfix branches? |
Unfortunately, this issue has taken on a much lower importance for me, and 2017-10-26 0:01 GMT-05:00 Berker Peksag <report@bugs.python.org>:
|
Thank you, all. The OP's snippet should work now: >>> import msilib as m
>>> db = m.OpenDatabase('py33.msi', m.MSIDBOPEN_TRANSACT)
>>> db.Commit()
>>> db2 = m.OpenDatabase('py33.msi', m.MSIDBOPEN_TRANSACT)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
_msi.MSIError: 1: 2203 2: py33.msi 3: -2147287008
>>> db.Close()
>>> db2 = m.OpenDatabase('py33.msi', m.MSIDBOPEN_TRANSACT) I didn't backport this to bugfix branches since we added a new public function to the API. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: