Skip to content

Instantly share code, notes, and snippets.

@kfelter
Created November 9, 2018 15:56
Show Gist options
  • Save kfelter/dd61aafc56d88b0c287a264b613a519e to your computer and use it in GitHub Desktop.
Save kfelter/dd61aafc56d88b0c287a264b613a519e to your computer and use it in GitHub Desktop.
This is a method for getting objects from hashes specifically using sqlite3 for the Destiny 2 API
import sqlite3
con = sqlite3.connect('Manifest.content')
cur = con.cursor()
def getItemName(itemHash):
#create id from hash
if (itemHash & (1 << (32 - 1))) != 0:
itemHash = itemHash - (1 << 32)
cur.execute("SELECT json FROM DestinyInventoryItemDefinition WHERE id=?", (itemHash,))
#print(cur.fetchall())
item = json.dumps(cur.fetchall()[0])
item = json.loads(json.loads(item)[0])
print(itemHash,item)
return item.get('displayProperties', {}).get('name', 'NA')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment