Skip to content

Instantly share code, notes, and snippets.

@alexmi256
Created June 17, 2025 14:41
Show Gist options
  • Select an option

  • Save alexmi256/8ef1f6bbe395c67c600819a28164380c to your computer and use it in GitHub Desktop.

Select an option

Save alexmi256/8ef1f6bbe395c67c600819a28164380c to your computer and use it in GitHub Desktop.
Photoprism Bulk Update via MariaDB SQL

What

This is how you can bulk update photo content via for Photoprism by modify the database since at this time the UI nor the CLI support somwething like this.

Photoprism Tables

root@53ccebcdacf5:/# mariadb-show --password=insecure --user=photoprism photoprism
Database: photoprism
+---------------------+
|       Tables        |
+---------------------+
| albums              |
| albums_users        |
| audit_logins        |
| auth_clients        |
| auth_sessions       |
| auth_users          |
| auth_users_details  |
| auth_users_settings |
| auth_users_shares   |
| cameras             |
| categories          |
| cells               |
| countries           |
| details             |
| duplicates          |
| errors              |
| faces               |
| files               |
| files_share         |
| files_sync          |
| folders             |
| keywords            |
| labels              |
| lenses              |
| links               |
| markers             |
| migrations          |
| passcodes           |
| passwords           |
| photos              |
| photos_albums       |
| photos_keywords     |
| photos_labels       |
| photos_users        |
| places              |
| reactions           |
| services            |
| subjects            |
| versions            |
+---------------------+

Photoprism Photos Table

root@53ccebcdacf5:/# mariadb-show --password=insecure --user=photoprism photoprism photos
Database: photoprism  Table: photos
+--------------------+------------------+--------------------+------+-----+---------------+----------------+---------------------------------+---------+
| Field              | Type             | Collation          | Null | Key | Default       | Extra          | Privileges                      | Comment |
+--------------------+------------------+--------------------+------+-----+---------------+----------------+---------------------------------+---------+
| id                 | int(10) unsigned |                    | NO   | PRI |               | auto_increment | select,insert,update,references |         |
| uuid               | varbinary(64)    |                    | YES  | MUL |               |                | select,insert,update,references |         |
| taken_at           | datetime         |                    | YES  | MUL |               |                | select,insert,update,references |         |
| taken_at_local     | datetime         |                    | YES  |     |               |                | select,insert,update,references |         |
| taken_src          | varbinary(8)     |                    | YES  |     |               |                | select,insert,update,references |         |
| photo_uid          | varbinary(42)    |                    | YES  | UNI |               |                | select,insert,update,references |         |
| photo_type         | varbinary(8)     |                    | YES  |     | x'696d616765' |                | select,insert,update,references |         |
| type_src           | varbinary(8)     |                    | YES  |     |               |                | select,insert,update,references |         |
| photo_title        | varchar(200)     | utf8mb4_unicode_ci | YES  |     |               |                | select,insert,update,references |         |
| title_src          | varbinary(8)     |                    | YES  |     |               |                | select,insert,update,references |         |
| photo_caption      | varchar(4096)    | utf8mb4_unicode_ci | YES  |     |               |                | select,insert,update,references |         |
| caption_src        | varbinary(8)     |                    | YES  |     |               |                | select,insert,update,references |         |
| photo_path         | varbinary(1024)  |                    | YES  | MUL |               |                | select,insert,update,references |         |
| photo_name         | varbinary(255)   |                    | YES  |     |               |                | select,insert,update,references |         |
| original_name      | varbinary(755)   |                    | YES  |     |               |                | select,insert,update,references |         |
| photo_stack        | tinyint(4)       |                    | YES  |     |               |                | select,insert,update,references |         |
| photo_favorite     | tinyint(1)       |                    | YES  |     |               |                | select,insert,update,references |         |
| photo_private      | tinyint(1)       |                    | YES  |     |               |                | select,insert,update,references |         |
| photo_scan         | tinyint(1)       |                    | YES  |     |               |                | select,insert,update,references |         |
| photo_panorama     | tinyint(1)       |                    | YES  |     |               |                | select,insert,update,references |         |
| time_zone          | varbinary(64)    |                    | YES  |     | x'4c6f63616c' |                | select,insert,update,references |         |
| place_id           | varbinary(42)    |                    | YES  | MUL | x'7a7a'       |                | select,insert,update,references |         |
| place_src          | varbinary(8)     |                    | YES  |     |               |                | select,insert,update,references |         |
| cell_id            | varbinary(42)    |                    | YES  | MUL | x'7a7a'       |                | select,insert,update,references |         |
| cell_accuracy      | int(11)          |                    | YES  |     |               |                | select,insert,update,references |         |
| photo_altitude     | int(11)          |                    | YES  |     |               |                | select,insert,update,references |         |
| photo_lat          | double           |                    | YES  | MUL |               |                | select,insert,update,references |         |
| photo_lng          | double           |                    | YES  | MUL |               |                | select,insert,update,references |         |
| photo_country      | varbinary(2)     |                    | YES  | MUL | x'7a7a'       |                | select,insert,update,references |         |
| photo_year         | int(11)          |                    | YES  |     |               |                | select,insert,update,references |         |
| photo_month        | int(11)          |                    | YES  |     |               |                | select,insert,update,references |         |
| photo_day          | int(11)          |                    | YES  | MUL |               |                | select,insert,update,references |         |
| photo_iso          | int(11)          |                    | YES  |     |               |                | select,insert,update,references |         |
| photo_exposure     | varbinary(64)    |                    | YES  |     |               |                | select,insert,update,references |         |
| photo_f_number     | float            |                    | YES  |     |               |                | select,insert,update,references |         |
| photo_focal_length | int(11)          |                    | YES  |     |               |                | select,insert,update,references |         |
| photo_quality      | smallint(6)      |                    | YES  |     |               |                | select,insert,update,references |         |
| photo_faces        | int(11)          |                    | YES  |     |               |                | select,insert,update,references |         |
| photo_resolution   | smallint(6)      |                    | YES  |     |               |                | select,insert,update,references |         |
| photo_duration     | bigint(20)       |                    | YES  |     |               |                | select,insert,update,references |         |
| photo_color        | smallint(6)      |                    | YES  |     | -1            |                | select,insert,update,references |         |
| camera_id          | int(10) unsigned |                    | YES  | MUL | 1             |                | select,insert,update,references |         |
| camera_serial      | varbinary(160)   |                    | YES  |     |               |                | select,insert,update,references |         |
| camera_src         | varbinary(8)     |                    | YES  |     |               |                | select,insert,update,references |         |
| lens_id            | int(10) unsigned |                    | YES  |     | 1             |                | select,insert,update,references |         |
| created_by         | varbinary(42)    |                    | YES  | MUL |               |                | select,insert,update,references |         |
| created_at         | datetime         |                    | YES  |     |               |                | select,insert,update,references |         |
| updated_at         | datetime         |                    | YES  |     |               |                | select,insert,update,references |         |
| edited_at          | datetime         |                    | YES  |     |               |                | select,insert,update,references |         |
| published_at       | datetime         |                    | YES  | MUL |               |                | select,insert,update,references |         |
| checked_at         | datetime         |                    | YES  | MUL |               |                | select,insert,update,references |         |
| estimated_at       | datetime         |                    | YES  |     |               |                | select,insert,update,references |         |
| deleted_at         | datetime         |                    | YES  | MUL |               |                | select,insert,update,references |         |
+--------------------+------------------+--------------------+------+-----+---------------+----------------+---------------------------------+---------+

SQL Query

You should obviously try and select photos to see if the counts seem good before you modify anything.

MariaDB [photoprism]> select COUNT(*) from photos WHERE LENGTH(photo_caption) = 3;
+----------+
| COUNT(*) |
+----------+
|      645 |
+----------+
1 row in set (0.012 sec)

You can modify via something like this:

root@53ccebcdacf5:/# mariadb --password=insecure --user=photoprism photoprism
UPDATE photos SET photo_caption = NULL WHERE CHAR_LENGTH(photo_caption) = 3;
``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment