RhetTbull / osxphotos

Python app to work with pictures and associated metadata from Apple Photos on macOS. Also includes a package to provide programmatic access to the Photos library, pictures, and metadata.
MIT License
2.17k stars 100 forks source link

Error exporting photo ...: Wrong database format! #459

Closed innoreq closed 2 years ago

innoreq commented 3 years ago

I'm trying to export several photos libraries using osxphotos. While the very first library could be exported without problems, the second one throws many (!) of these errors:

Error exporting photo (281500D0-AB76-47B7-BC1F-3B50CFCF49B6: DHAT9410.JPG) as DHAT9410.JPG: Wrong database format!

However, some pictures are in fact exported. I did a photos library repair (ALT-CMD-Start), but this had no effect.

osxphotos version: 0.42.28 macos version: 11.4 Beta (20F5046g) photos version: 6.0 (350.0.100)

RhetTbull commented 3 years ago

What's the full command line you're using for export?

This isn't an osxphotos error, it's one that osxphotos is catching and reporting from the OS. I'm not sure the cause but will look into it.

innoreq commented 3 years ago

Oh, sorry, totally forgot that thing:

osxphotos export --db --directory "{created.year}/{place.name.country}" --update --sidecar XMP

innoreq commented 3 years ago

Some more stuff from the most recent run on a different library:

2021-06-04 12:10:20,759 - WARNING - photosdb.py - 97 - WARNING: This module has only been tested with macOS versions [10.12, 10.13, 10.14, 10.15, 10.16, 11.0, 11.1, 11.2, 11.3]: you have Darwin, OS version: 11.4 WARNING: Only tested on database versions [6000, 4025, 4016, 3301, 2622] You have database version=5001 which has not been tested Exporting 32167 photos to /Volumes/P03c Bilder/Export xxx…x [------------------------------------] 0% Traceback (most recent call last): File "/Users/xxx/.local/pipx/venvs/osxphotos/lib/python3.9/site-packages/osxphotos/photoinfo/photoinfo.py", line 217, in path_edited return self._path_edited AttributeError: 'PhotoInfo' object has no attribute '_path_edited'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/xxx/.local/bin/osxphotos", line 8, in sys.exit(cli()) File "/Users/xxx/.local/pipx/venvs/osxphotos/lib/python3.9/site-packages/click/core.py", line 1137, in call return self.main(args, kwargs) File "/Users/xxx/.local/pipx/venvs/osxphotos/lib/python3.9/site-packages/click/core.py", line 1062, in main rv = self.invoke(ctx) File "/Users/xxx/.local/pipx/venvs/osxphotos/lib/python3.9/site-packages/click/core.py", line 1668, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/Users/xxx/.local/pipx/venvs/osxphotos/lib/python3.9/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, ctx.params) File "/Users/xxx/.local/pipx/venvs/osxphotos/lib/python3.9/site-packages/click/core.py", line 763, in invoke return __callback(args, kwargs) File "/Users/xxx/.local/pipx/venvs/osxphotos/lib/python3.9/site-packages/click/decorators.py", line 38, in new_func return f(get_current_context().obj, *args, *kwargs) File "/Users/xxx/.local/pipx/venvs/osxphotos/lib/python3.9/site-packages/click/decorators.py", line 26, in new_func return f(get_current_context(), args, kwargs) File "/Users/xxx/.local/pipx/venvs/osxphotos/lib/python3.9/site-packages/osxphotos/cli.py", line 1581, in export export_results = export_photo( File "/Users/xxx/.local/pipx/venvs/osxphotos/lib/python3.9/site-packages/osxphotos/cli.py", line 2292, in export_photo if photo.hasadjustments and photo.path_edited is None: File "/Users/xxx/.local/pipx/venvs/osxphotos/lib/python3.9/site-packages/osxphotos/photoinfo/photoinfo.py", line 222, in path_edited self._path_edited = self._path_edited_5() File "/Users/xxx/.local/pipx/venvs/osxphotos/lib/python3.9/site-packages/osxphotos/photoinfo/photoinfo.py", line 242, in _path_edited_5 raise RuntimeError("Wrong database format!") RuntimeError: Wrong database format!

RhetTbull commented 3 years ago

Thanks -- that's helpful.

On the command line, I assume you're actually including the path to the Photos library (otherwise you should get an error):

osxphotos export --db --directory "{created.year}/{place.name.country}" --update --sidecar XMP

should be

osxphotos export --db /path/to/library --directory "{created.year}/{place.name.country}" --update --sidecar XMP

WARNING: Only tested on database versions [6000, 4025, 4016, 3301, 2622] You have database version=5001

It appears you've got a Photos database version that I've never seen in my testing (which has covered 10.12 through 11.3). (and thus my earlier comment about this not being an osxphotos error was wrong). Do you know which version of macOS these were created on? I'll need to see a copy of one of these databases or at least the schema to know if osxphotos can process these correctly. Please run these two commands and post the output here (they'll show only schema information, no actual personal details from your library):

sqlite3 ~/Pictures/Photos\ Library.photoslibrary/database/photos.db ".schema" > db_schema.txt

sqlite3 ~/Pictures/Photos\ Library.photoslibrary/database/photos.sqlite ".schema" > sqlite_schema.txt

In the commands above, replace ~/Pictures/Photos\ Library.photoslibrary/ with the path to the library that's causing the error.

innoreq commented 3 years ago

yeah, sure. I applied placeholders in greater-and-smaller-than-brackets, but the GitHub editor seems to have eaten that... Another info: I just downgraded to BigSur release (not beta), but that didn't change the problem.

RhetTbull commented 3 years ago

See also #102 I need to see the schema for one of these "version 5001" databases to know which queries to use against these databases.

RhetTbull commented 3 years ago

@innoreq If you can run the two sqlite3 commands above, I should have enough data to fix this. I think it's a relatively easy fix but need to see the schema of this particular Photos library format.

RhetTbull commented 2 years ago

I think this is fixed in v0.44.8