So apparently I’ve been doing way too much work with my flat file parsing of the Alsherok files. I forgot a very key component of my database of choice, PostgreSQL: ability to act as a non-relational database such as MongoDB while retaining the power of an RDBMS! I know, that last sentence is kinda geeky. Essentially, I just needed to grab the section I wanted, turn it into JSON, and shove it directly into the database. After that, I can call the data back out using a hybrid of traditional SQL such as:
1 2 3 | select data->>;'Name' as Name , data->>;'Minlevel' as Level from skills; |
Which brings back the fields
as expected.
1 2 3 4 5 6 | name,level reserved~,101 "acetum primus~",60 "acid blast~",15 "acid breath~",101 ... |
I can even ensure uniqueness by adding a unique index on a particular branch of the JSON:
1 | create UNIQUE INDEX skills_name on skills ((data->>'Name')); |
This provides a unique entry and fast searching because.. you know.. indexes and stuff.
Needless to say, I felt the need to refactor the other flat files I’ve finished and make them all spit out JSON instead of complex table structures 😉 Thankfully that went much faster than writing them originally. I may actually meet my end of the month deadline after all.
Recent Comments