Skip to content

Instantly share code, notes, and snippets.

@ambiamber
Last active September 15, 2022 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ambiamber/f3fbe4ac0baa61bf0912233ef3900db6 to your computer and use it in GitHub Desktop.
Save ambiamber/f3fbe4ac0baa61bf0912233ef3900db6 to your computer and use it in GitHub Desktop.
Notes on exporting Partkeepr attachments.
Note that I only have one image attachment in my Partkeepr.
$ sudo mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 205
Server version: 10.1.48-MariaDB-0+deb9u2 Debian 9.13
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> use partkeepr
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [partkeepr]> select * from PartAttachment;
+----+---------+----------------+--------------------------------------+------------------+-----------+-------+-----------+-------------+---------------------+---------+
| id | part_id | type | filename | originalname | mimetype | size | extension | description | created | isImage |
+----+---------+----------------+--------------------------------------+------------------+-----------+-------+-----------+-------------+---------------------+---------+
| 1 | 52 | PartAttachment | 0a1b32ce-3498-11ed-9f3e-c535ea89570f | coffee beans.png | image/png | 61026 | | NULL | 2022-09-14 21:45:12 | NULL |
+----+---------+----------------+--------------------------------------+------------------+-----------+-------+-----------+-------------+---------------------+---------+
1 row in set (0.00 sec)
The pathname in the web server diretory plus the value in the filename column plus the extention from the originalname (or from the MIME type image/png) will be the complete filename of the image.
/var/www/partkeepr/data/files/PartAttachment/0a1b32ce-3498-11ed-9f3e-c535ea89570f.png
THe part_id column in the PartAttachment table is named id in the Part table.
MariaDB [partkeepr]> select * from Part where id = '52';
+----+-------------+--------------+--------------+-------------+---------+------------+---------------+--------------+--------+-------------+---------------+-------------------+---------------------+--------------------+----------+----------+----------+-------------+--------------------+
| id | category_id | footprint_id | name | description | comment | stockLevel | minStockLevel | averagePrice | status | needsReview | partCondition | productionRemarks | createDate | internalPartNumber | removals | lowStock | metaPart | partUnit_id | storageLocation_id |
+----+-------------+--------------+--------------+-------------+---------+------------+---------------+--------------+--------+-------------+---------------+-------------------+---------------------+--------------------+----------+----------+----------+-------------+--------------------+
| 52 | 5 | NULL | Coffee beans | | | 1 | 0 | 0.0000 | | 0 | | | 2022-09-14 06:23:47 | | 0 | 0 | 0 | 1 | 4 |
+----+-------------+--------------+--------------+-------------+---------+------------+---------------+--------------+--------+-------------+---------------+-------------------+---------------------+--------------------+----------+----------+----------+-------------+--------------------+
1 row in set (0.00 sec)
There may be a way to do a custom export to save the contents of both the PartAttachment table along with the Part table.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment