entity-attribute-value export

Tell us about your wildest feature dreams. Or just harmless suggestions for improvement.
Post Reply
gh451565
Junior Member
Junior Member
Posts: 2
Joined: Mon Apr 06, 2009 8:29 am

entity-attribute-value export

Post by gh451565 »

I would very much like a way of exporting in entity-attribute-value format. Here's why. I have an online store that cells various types of products. A shirt might have a "sex" associated with it, but certainly a book doesn't. Similarly, a book has an author, a number of pages, etc but a DVD doesn't. The online store I have uses Virtuemart, which has an EAV table for "nonstandard" product attributes. While frowned upon among database purists, they are all too common in the kind of canned package I'm using and I'd rather not get my hands dirty with too much php.

Does anyone have a template for this sort of thing? Ideally, the user could select a column to use for product-ids (e.g. the ISBN column) and which columns are to become "attributes". The result would be a 4-column table
primary key-productid-attributename-attributevalue

I could then export this directly to my MySQL tables. Would something like this be possible?
User avatar
Conor
Top Dog
Posts: 5346
Joined: Sat Jul 03, 2004 12:58 pm
Contact:

Re: entity-attribute-value export

Post by Conor »

You can build your own text template that would do this. Create an empty text.txt file in ~/Library/Application Support/Bookpedia/Templates (you might have to create the templates folder). Then fill the file with something along these lines:

Code: Select all

<!--BeginRepeat-->
[key:uid]-[key:isbn]-title-[key:title]
[key:uid]-[key:isbn]-author-[key:author]
[key:uid]-[key:isbn]-price-[key:price]
... any other attributes you would like to export
<!--EndRepeat-->
If you are looking to move the data to MySQL then take a look at the actual database file (~/Library/Application Support/Bookpedia/Database.bookpd) this is an SQLite file that can be opened with SQLite from the Terminal (sqlite3 ~/Library/Application Support/Bookpedia/Database.bookpd) and dumped directly into SQL format (.dump). Make a backup of the file if you plan on working with it, any change by mistake might render the file unreadable to Bookpedia.
gh451565
Junior Member
Junior Member
Posts: 2
Joined: Mon Apr 06, 2009 8:29 am

Re: entity-attribute-value export

Post by gh451565 »

Thanks for your helpful reply! After some contortions, I realized I don't need to deal with entity-attribute-value, I can create a "product type" for books, and this gets its own table with "product id" as a foreign key (if I were designing the database, that's how I'd do it too, using EAV only for dire emergencies). Since most of the products will be books this makes more sense.

But the tips about using Bookpedia's backend database are very helpful indeed. I'll try to post if I'm successful.
Post Reply