PennyDreadfulMTG / Penny-Dreadful-Tools

A suite of tools for the Penny Dreadful MTGO community
https://pennydreadfulmagic.com
MIT License
39 stars 28 forks source link

Unable to perform db setup #4140

Closed bakert closed 6 years ago

bakert commented 6 years ago
[deepthought pd] python run.py maintenance reprime_cache
Unable to initialize oracle. I'll build it now. If this is happening on user time this is bad. Failed to execute `SELECT * FROM _cache_card AS c WHERE ((1 = 1) AND (1 = 1))` with `[]` because of `(1146, "Table 'magic._cache_card' doesn't exist")`
Fetching https://mtgjson.com/json/version.json (cache ok)
Database update required
Storing https://mtgjson.com/json/AllCards-x.json.zip in /Users/bakert/.Penny-Dreadful-Discord-Bot/zip/zip.zip
Storing https://mtgjson.com/json/AllSets.json.zip in /Users/bakert/.Penny-Dreadful-Discord-Bot/zip/zip.zip
Traceback (most recent call last):
  File "/Users/bakert/pd/shared/database_mysql.py", line 45, in execute
    self.cursor.execute(sql, args)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/MySQLdb/cursors.py", line 250, in execute
    self.errorhandler(self, exc, value)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler
    raise errorvalue
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/MySQLdb/cursors.py", line 247, in execute
    res = self._query(query)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/MySQLdb/cursors.py", line 411, in _query
    rowcount = self._do_query(q)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/MySQLdb/cursors.py", line 374, in _do_query
    db.query(q)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/MySQLdb/connections.py", line 277, in query
    _mysql.connection.query(self, query)
_mysql_exceptions.ProgrammingError: (1146, "Table 'magic._cache_card' doesn't exist")

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/bakert/pd/decksite/__init__.py", line 13, in <module>
    oracle.init()
  File "/Users/bakert/pd/magic/oracle.py", line 17, in init
    for c in load_cards():
  File "/Users/bakert/pd/magic/oracle.py", line 65, in load_cards
    rs = db().execute(sql)
  File "/Users/bakert/pd/shared/database_mysql.py", line 56, in execute
    raise DatabaseException('Failed to execute `{sql}` with `{args}` because of `{e}`'.format(sql=sql, args=args, e=e))
shared.pd_exception.DatabaseException: Failed to execute `SELECT * FROM _cache_card AS c WHERE ((1 = 1) AND (1 = 1))` with `[]` because of `(1146, "Table 'magic._cache_card' doesn't exist")`

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "run.py", line 77, in <module>
    run()
  File "run.py", line 32, in run
    task(sys.argv)
  File "run.py", line 51, in task
    from decksite.main import APP
  File "/Users/bakert/pd/decksite/__init__.py", line 16, in <module>
    multiverse.init()
  File "/Users/bakert/pd/magic/multiverse.py", line 22, in init
    update_database(current_version)
  File "/Users/bakert/pd/magic/multiverse.py", line 122, in update_database
    insert_set(s)
  File "/Users/bakert/pd/magic/multiverse.py", line 248, in insert_set
    card_id = CARD_IDS[card_name(c)]
KeyError: 'Mayor of Avabruck // Howlpack Alpha'
[deepthought pd] python run.py maintenance reprime_cache
Unable to initialize oracle. I'll build it now. If this is happening on user time this is bad. Failed to execute `SELECT * FROM _cache_card AS c WHERE ((1 = 1) AND (1 = 1))` with `[]` because of `(1146, "Table 'magic._cache_card' doesn't exist")`
Fetching https://mtgjson.com/json/version.json (cache ok)
Database update required
Storing https://mtgjson.com/json/AllCards-x.json.zip in /Users/bakert/.Penny-Dreadful-Discord-Bot/zip/zip.zip
Storing https://mtgjson.com/json/AllSets.json.zip in /Users/bakert/.Penny-Dreadful-Discord-Bot/zip/zip.zip
Traceback (most recent call last):
  File "/Users/bakert/pd/shared/database_mysql.py", line 45, in execute
    self.cursor.execute(sql, args)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/MySQLdb/cursors.py", line 250, in execute
    self.errorhandler(self, exc, value)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler
    raise errorvalue
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/MySQLdb/cursors.py", line 247, in execute
    res = self._query(query)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/MySQLdb/cursors.py", line 411, in _query
    rowcount = self._do_query(q)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/MySQLdb/cursors.py", line 374, in _do_query
    db.query(q)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/MySQLdb/connections.py", line 277, in query
    _mysql.connection.query(self, query)
_mysql_exceptions.ProgrammingError: (1146, "Table 'magic._cache_card' doesn't exist")

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/bakert/pd/decksite/__init__.py", line 13, in <module>
    oracle.init()
  File "/Users/bakert/pd/magic/oracle.py", line 17, in init
    for c in load_cards():
  File "/Users/bakert/pd/magic/oracle.py", line 65, in load_cards
    rs = db().execute(sql)
  File "/Users/bakert/pd/shared/database_mysql.py", line 56, in execute
    raise DatabaseException('Failed to execute `{sql}` with `{args}` because of `{e}`'.format(sql=sql, args=args, e=e))
shared.pd_exception.DatabaseException: Failed to execute `SELECT * FROM _cache_card AS c WHERE ((1 = 1) AND (1 = 1))` with `[]` because of `(1146, "Table 'magic._cache_card' doesn't exist")`

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "run.py", line 77, in <module>
    run()
  File "run.py", line 32, in run
    task(sys.argv)
  File "run.py", line 51, in task
    from decksite.main import APP
  File "/Users/bakert/pd/decksite/__init__.py", line 16, in <module>
    multiverse.init()
  File "/Users/bakert/pd/magic/multiverse.py", line 22, in init
    update_database(current_version)
  File "/Users/bakert/pd/magic/multiverse.py", line 122, in update_database
    insert_set(s)
  File "/Users/bakert/pd/magic/multiverse.py", line 248, in insert_set
    card_id = CARD_IDS[card_name(c)]
KeyError: 'Mayor of Avabruck // Howlpack Alpha'
silasary commented 6 years ago

I'm assuming something changed when https://github.com/mtgjson/mtgjson/pull/540/ (From the Vault: Transform) was merged in.

bakert commented 6 years ago

The order in which names are listed has changed.

Before:

  "Howlpack Alpha": {
    "layout": "double-faced",
    "name": "Howlpack Alpha",
    "names": [
      "Mayor of Avabruck",
      "Howlpack Alpha"
    ],

Now:

  "Howlpack Alpha": {
    "layout": "double-faced",
    "name": "Howlpack Alpha",
    "names": [
      "Howlpack Alpha",
      "Mayor of Avabruck"
    ],

Note: for both Howlpack Alpha AND Mayor of Avabruck entries they used to sort "correctly" and now sort this other way. Ironfang/Village Messenger and Huntmaster of the Fells/Ravager of the Fells are similarly affected.

bakert commented 6 years ago

Logged https://github.com/mtgjson/mtgjson/issues/548 with mtgjson and pursuing.

jgabrielygalan commented 6 years ago

Confirmed, I tested removing all double-faced cards from AllSets.json and it worked.

silasary commented 6 years ago

This is also breaking Scraper.

jgabrielygalan commented 6 years ago

There's a problem with meld cards too. We are expecting them to have 3 names, and that's true for AllCards, but not true for AllSets. I guess they had 3 names in both files before. This is what they have now:

    "name": "Bruna, the Fading Light",
    "names": [
      "Bruna, the Fading Light",
      "Brisela, Voice of Nightmares"
    ],

I've checked mtgjson and Bruna has 3 names in EMN.json and only 2 in V17.json

bakert commented 6 years ago

This is hacked around and removing the hack is covered by #4230.