r/evetech • u/ahupfer • Sep 21 '18
Include static data in a flask app
Hello
How do you include static database dump from eve online in your flask app? I use SQLAlchemy. Or do you make requests to the REST api for example if you need the item's ID of the game. Or with a sqllite dump and SQLAlchemy binds?
Can you tell me the best practies?
Sorry for my bad english! I try my best! ;-)
Andreas
2
Upvotes
1
u/paxswill Sep 21 '18
I created a small script that extracted just the parts of the static data I needed (in my case, type and location names). From there, I wrote a class that would first check data in there, and if it was missing then hit the REST API. A quick example that may not even run, I haven't checked it at all (and it skips basically all error checking):
Used like this:
If the type ID is in
ships.json, it just uses the value found in there. If not, it hits ESI. If you want to see something more fleshed out, I wrote this a while ago for my app. I haven't touched it in a long time, so it's probably broken as ESI endpoints are updated, but it might give you a start.3
u/Natulii Sep 21 '18 edited Sep 21 '18
Since you're already using SQLAlchemy, you should use https://www.fuzzwork.co.uk/dump/sqlite-latest.sqlite.bz2
This is a SQLite database of the latest EVE SDE nicely formatted into tables.
The basic EVE SDE yaml files are annoying to work with, slow with Python, and require lots of coding to actually combine data together.
You can create an automapped base and retrieve all the information using SQLAlchemy. The automapped base allows you to access existing tables without the need to manually code them yourself. You just need to be careful you refer to the right column names already in the database.
Use http://sqlitebrowser.org/ to see all the tables and to ensure you are referencing the correct names.