• 0
Ian-D

LEGO Database Download page - suggestions

Question

On the - LEGO Database Download page, there is a link for part_relationships.csv but part_relationship is not shown on the diagram.

Not a major problem, just a suggested change.

Another nice to see, would be the column types used for each field (EG, I assume most are just string on Integer)

I am have just started looking at Rebrickable, and I think it would be useful if I created my own local database (MySQL or PostgreSQL or LibreOffice Base maybe?) that I can then keep in sync with Rebrickable.  Does anyone have any suggestions on which and how (sorry, should this part be moved to another area of the Forum?)

Regards, Ian
.

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Hi Ian,

I have an ugly little workflow that I knocked together in Python (mainly using Pandas), with Dropbox to move the result around, and Google Sheets to view it.  It runs nightly from my local machine and pulls out all my parts list into a single CSV (with a column indicating which Rebrickable part list the part is from).  It creates a date-stamped version of the CSV (for backup) and a "always the latest" version.  The latter is synced to Dropbox and I have a Google Sheet that reads it live (using the IMPORTDATA function).  

This workflow gives me a backup of my parts lists and and a quick way to search for parts in Google Sheets if I don't want to go through the Rebrickable interface.  I find that I use both Rebrickable and the Google Sheet depending on what I'm doing. Also, as an intended benefit, I can go back through the date-stamped versions to see how my parts total has changed over time, which is probably about the nerdiest thing I've ever done for fun. 

If that sounds like it might be helpful to you, send me a DM, and I can send you the script.  You'd need to be comfortable in python to make any sense of it, but it sounds like you probably are.

--cj

Share this post


Link to post
Share on other sites
  • 0

Hi CJ, I have written (hacked?!) python progs in the past (V2 or V3?), and that script sounds like a useful springboard for what I want to do.

You have also got me thinking how I might upload to Rebrickable too - to sync from any other lego source I might use - as it is too easy to buy something you did not think you had - and find you did have...  And checking the quantities, etc.

Right - now to find where to DM you  :-)

Cheers, Ian

Share this post


Link to post
Share on other sites
  • 0

Hi Ian.  It's in python 3.  I'll send it by DM. 

For uploads into your parts lists, Rebrickable has great import functionality from almost any source you care to work with via the interface.   For my initial inventory (for which I spent a long time counting a lot of parts), I entered the inventory into a csv and imported that.  There's nice error reporting in the interface to help catch mistakes.  I've also imported directly from Bricklink and Brickowl orders using the Rebrickable interface.  All of those work reliably for me, so I haven't felt the need to build anything for uploads (or even set up a local db beyond the CSVs the script generates), but of course everyone's workflow is a bit different.  It's awesome that Rebrickable makes that flexibility possible via the API. 

Share this post


Link to post
Share on other sites
  • 0
On 4/11/2019 at 11:42 AM, Ian-D said:

On the - LEGO Database Download page, there is a link for part_relationships.csv but part_relationship is not shown on the diagram.

I am chipping away at my local database, and then will work out scripts to upload/download/etc...

I am working up the commands to build the database, tables, etc into a PostgreSQL database, and I now see that the rebrickable database parts table requires the material table, which is not currently available on the download page.  Could this be added please?

Ala :

CREATE TABLE parts (part_num VARCHAR PRIMARY KEY,name VARCHAR,part_cat_id SMALLINT NOT NULL REFERENCES part_categories(id),part_material_id SMALLINT NOT NULL REFERENCES material(material_id));

I am happy enough to guess at the data types, but it would also be handy to understand what some of the data values mean.  EG which value ("M","P","T","A") in part_relationships(rel_type) relate to : "Mold", "Print", "Pattern", "Pair" or "Alternative"? (I could not see a 5th value currently used).

I am happy to share more on my progress on this if the community/admins think it useful, but am not sure where would be best for that.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now