CrudVision - Lisa Seelye

July 30, 2008

Eve Online Empyrean Age 1.0 Database Dump for PostgreSQL

Filed under: eve online, open source, postgres, sql — Lisa Seelye @ 18:29

Today CCP announced the release of their MS SQL dump. Following in step with past conversions here is a Postgres version. Tested with 8.0.15 but should work on everything.

This dump is odd: CCP is using integers where they mean to use booleans. So in those cases remember 1 is true, 0 is false. Good luck.

Edit: As a note the Eve Online Database Viewer is updated with this dump.

Edit 2 (July 31, 2008): I nearly forgot to give props to bunjiboys for providing the .sql files from which the above dump is derrived.

December 9, 2007

Eve Online Trinity Database dump

Filed under: eve online, postgres, sql — Lisa Seelye @ 15:58

As I’ve done for previous Eve Online database dumps here’s a Postgres (8.1) dump for Trinity. Hosted at http://www.eve-files.com and can be downloaded by clicking on right here

Included in the zip archive is a Schema file as well as each individual table as a .sql file. They’re numbered 001 to 065. 001 is the schema (001_schema.sql) and is intended to be imported first. The others have no real order as there are no foreign key constraints but were numbered for my testing and sanity.

View the dump online

December 7, 2007

She does a little PHP, too

Filed under: eve online, php, postgres, sql — Lisa Seelye @ 22:44

I don’t like it but I’ll do it. :)

I rewrote my Eve Online Database Viewer. With the recent Trinity Dump (Postgres version coming soon) I wanted to rewrite the PHP script in order to better make use of mod_rewrite and to better handle errors.

September 2, 2007

Eve Online Revelations 2.2 Postgres Database Dump

Filed under: eve online, postgres, sql — Lisa Seelye @ 16:08

Just finished a Postgres port of the latest Eve Revelations database dump (as of the 2.2 patch). It can be downloaded from eve-files and can be browsed online at http://lisa.thedoh.com/projects/EO/?db=Rev22

I hope it’s useful for everyone.

August 6, 2007

Postgres “gotcha”

Filed under: postgres, snippet — Lisa Seelye @ 08:45

In my evedb.info efforts I need a quick way to expire old market orders. The CSV has a duration column that is an integer number of days. Postgres allows its users to typecast between various data types in SQL so there doesn't need to be a SELECT duration FROM ... ; (in code) to_delete = Time.now + duration.days ; DELETE FROM ... WHERE duration < to_delete;

It just so happens that the form for casting an integer to do math with a timestamp is a bit funky. An integer may not be directly added to a timestamp. The magic is:

SQL:
  1. DELETE
  2. FROM foo
  3. WHERE now()> (created_on + CAST( (duration || ' days') AS INTERVAL));

The || ' days' I don't understand just yet but it works!

July 17, 2007

Eve Online dump part 2.

Filed under: evedb.info, postgres — Lisa Seelye @ 23:08

Following up to this post of mine. The schema can be found here and the full thing (including Schema) can be found here.

July 15, 2007

One more reason why REST is good

Filed under: REST, crud, evedb.info, postgres, rails, ruby — Lisa Seelye @ 09:30

In my quest to RESTify Evedb.info I keep finding more reasons to fawn ove REST (and CRUD): With the most recent Eve Online Database Dump for Revelations I have a need to migrate the data to my own schema. I also need to treat the database dump as a "Master" copy of what should appear in my site; stale data must be removed from my database.

I like to automate things. Prior to the RESTification efforts I would pump out raw SQL files and import them into Postgres in a batch. The SQL took about 45 minutes to import and was often held up due to foreign key issues.

Anyways, with REST I can funnel all of that through my controllers which have that functionality anyways (albeit heavily secured so normal users can't use this CUD API). I can have the same standard method for updating my version of CCP's data.

CCP has a lot of extra data in its Database dump (read: I don't use every column from every table). When I felt the need to import one of those I had to mess about with SQL files. Evedb.info was not using migrations! The SQL files were too big to be under source control. And a better solution was needed.

Enter: Evedb::Updater.

I wrote a class today to use the libcurl libraries for Ruby since the native Ruby Net::HTTP libraries were giving me trouble with the encoding of POST data. The general structure of the class I wrote is the following:

  1. Initalise the environment (Create a Postgres connection, Curl object, and store the base URL)
  2. Get a list of all of the IDs of the current model I'm dealing with (custom controller method all_ids since I have index paginated)
  3. Process an SQL query designed to do the schema change (
    SQL:
    1. SELECT agentid AS id FROM agtAgents

    ) for the specific model. This results in a list of things to create, update and destroy

  4. Do the deletions
  5. Do the creates
  6. Do the updates

It was a fun bit of code to write! The highlight is probably this bit:

RUBY:
  1. module Hash
  2.   def to_curl
  3.     [] if self.keys.empty?
  4.     ret = []
  5.     self.keys.each do |k|
  6.       self[k].each do |v,l|
  7.         ret <<Curl::PostField.content("#{k.to_s}[#{v.to_s}]",l.to_s)
  8.       end
  9.      end
  10.     ret
  11.   end
  12. end

The hash is generated by

RUBY:
  1. 0.upto(sql_results.num_tuples - 1) do |i|
  2.   m = { type => {} }
  3.   sql_results.fields.each do |field|
  4.     m[type].merge!( { field.to_sym => sql_results.getvalue(i,sql_results.fieldnum(field)).rstrip.fixmscrap.gsub(/'/,'\\\\\'') } )
  5. end

The result of the to_curl method is to make the POST data that how we rails folk like it! (agent[name]=foo).

One downside to this is that some models need to query the Rails database (not the CCP one) for information to use. I might be better off modifying those specific models to use virtual attributes and some clever use of before_create!

July 13, 2007

Eve Online Database Dump (Revelations 2)

Filed under: evedb.info, postgres — Lisa Seelye @ 08:11

Last night I got my hands on the latest db dump and converted it to a Postgres format. Currently the "online version" (basically a PHP script to sort all the info!) is online for browsing for those who may be interested.

I think I'll pg_dump and pop the resulting SQL on Eve files so others can have it.

Powered by WordPress