mirror of
https://gitlab.com/jrmiller82/pathfinder-2-sqlite.git
synced 2026-10-12 22:29:44 -04:00
working on traits to yaml
This commit is contained in:
1 parent
0bcfd98e46
commit
bf2c0b1605
2 files changed
+1362
No files matched your search
@@ -0,0 +1,34 @@
|
||||
import sqlite3
|
||||
import yaml
|
||||
|
||||
def main():
|
||||
q = """
|
||||
select traits.short_name, traits.description, traittypes.name FROM traits INNER JOIN traittypes ON traits.traittype=traittypes.traittype_id;
|
||||
"""
|
||||
|
||||
conn = sqlite3.connect('../../pf2.db')
|
||||
|
||||
c = conn.cursor()
|
||||
|
||||
c.execute(q)
|
||||
data = c.fetchall()
|
||||
|
||||
# transform tuples into list of dicts
|
||||
|
||||
datalist = []
|
||||
|
||||
for i in data:
|
||||
print(i)
|
||||
d = { 'type': i[2], 'name': i[0], 'descr': i[1]}
|
||||
datalist.append(d)
|
||||
|
||||
tmpd = { 'trait': datalist }
|
||||
|
||||
# now dump to yaml
|
||||
final = yaml.safe_dump(tmpd, allow_unicode=True)
|
||||
with open('tmp-traits.yaml', 'w') as f:
|
||||
f.write(final)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user