mtgjson / mtgsqlive

MTGJSON build scripts to generate alternative data formats
https://mtgjson.com
MIT License
54 stars 32 forks source link

Need explanation of the generate_sql_schema function #56

Closed ghost closed 4 years ago

ghost commented 4 years ago

Hello thanks a lot for the time you've taken to do this script. I need to get a database with tix, usd and eur prices, so I can use this sql and add the prices from scryfall or convert the scryfall json directly without using the mtgjson file. For both I would need to know how the script works to modify it. The problem is I've understood everything except the generate_sql_schema function, because I can't open the json, it makes my computer freeze because it's too big, and I can't follow the logic of the function. Could you write down in a docstring for that function or maybe here or in the readme what's the "json data" look like and what's the sql result? (I don't know how to call the "json data", what I mean is the keys without the actual data, what would be the relations or table names in the sql database")

And if you could split that function and add more comments to it so it gets easier to follow it's logic, it would be really nice.

I've also refactored some of the code to better understand it, you probably may want to add some of the changes: https://pastebin.com/35Wqvdri I haven't tested it that's why I didn't make a pull request.

ZeldaZach commented 4 years ago

Hey @ajr-dev we're always accepting of PRs if you'd like to propose a change. This project is maintained by @omfgitsmark so he's probably the best one to weight in on how the operations take place.

I'm pretty sure we already account for prices within the SQL, but I could be wrong. Mark, any info?

ghost commented 4 years ago

I'm pretty sure we already account for prices within the SQL, but I could be wrong.

Yes I think you are storing a history of prices the problem is I can't open any of the json files so I don't know which prices are you storing, but I guess they are usd prices. I know scryfall has tix, usd, and eur. If mtgjson has those too then I can just use the sql from mtgjson and I won't need to adapt it for scryfall. Although I only need the last price and not the whole history but that's probably something I can easily fix.

ZeldaZach commented 4 years ago

We have online, paper, and European prices too. Online = CardHoarder pricing, Paper = TCGPlayer & Card Kingdom pricing, European = MKM Pricing.

We should pull together more docs on the SQL for better use cases.

FYI, You can expand the JSON with jsonlint and then it should load in sublime easily

ghost commented 4 years ago

Wow that's nice then I can just use your sql database. So I was going to use the 30 day average from MKM that scryfall uses as it's european pricing. Does mtgjson use that too? And how often is it updated? Thanks.

omfgitsmark commented 4 years ago

There's a lot to unpack here so I'll do my best.

I hope this helps, I think I hit everything, but if you have any more specific questions I will do my best to answer them.