12.07.2015 Views

The Computational Materials Repository

The Computational Materials Repository

The Computational Materials Repository

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2.6 Modifying Data in the Database 41the dynamic part are the user added keywords, fields and attached files. Thismeans that the UI only changes when something unexpected is modified - andprevents therefore overwriting of good with false data. <strong>The</strong>re is a big advantageof having the UI calculated from the data and stored in the db-files and assignedby the MySQL database: the identifier is globally unique and as a consequencedata exchange with other databases is possible without conflicts. Additionallythe queries written for one database can be used with an other as well.<strong>The</strong> right way to update a data in the database is to retrieve it, modify itand then upload it again. <strong>The</strong> assumption that converting the original file againand uploading the new db-file to the database will overwrite the existing one iswrong. <strong>The</strong> data is added, but does not overwrite anything because the createdUI is different for every conversion.In seldom cases we have to upload an “old” file and overwrite a newer one.Overwriting in the database created by CMR is similar to a file system wherefiles are overwritten when a file with the same name is added to a directory.Normally there is an option that prevents newer files to be overwritten by olderones. This is the default in CMR: only files with a newer last modified timestamp than the one already in the database can overwrite. As a consequencewhen uploading older files the last modified time stamp must be updated andthis happens, when the db-file is changed or if a the file is touched. <strong>The</strong> easiestway is to use touch which is available in the command line interface:cmr −−touch∗ . dband also in the python interface:cmr . touch ( ‘ ‘ name . db ’ ’ )# or i f the f i l e i s i n memory or j u s t loaded from the databasedata = cmr . read ( ‘ ‘ name . db ’ ’ )data . touch ( )data . w r i t e ( ‘ ‘ name . db ’ ’ )After touching the db-files need to be re-uploaded.Using the results of a colleague is easy at CAMD because there is a hugedatabase deployed that everyone can access. Regularly people don’t like tomodify someone else’s data - and it is also risky to not have full control over thedata. In this case it is easier to own it. Owning means to copy the data andreplace the user name with the own one. <strong>The</strong> command own does this and isavailable in the CLI:cmr −−own ∗ . dbcmr −−commit ∗ . db # upload to databaseand also in the python interface:cmr . own ( ’ name . db ’ )# or i f the f i l e i s i n memory or j u s t loaded from the databasedata = cmr . read ( ’ name . db ’ )data . own ( )data . w r i t e ( ’ . db ’ ) # w r i t e d i r e c t l y to database

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!