以下からPythonコードを実行すると、このエラーが発生します
'dict_items' object does not support indexing
https://github.com/commodo/geonames-dump-to-sqlite/blob/master/geonames_dump_to_sqlite.py
コードが行うことは、ジオネームからファイルを取得し、その結果を sqlite データベースに入れることです。
テーブルを作成するまでは問題なく動作します
def create_tables(cur):
'''
Create empty tables which will be populated later.
'''
for table_name in TABLE_MAPPINGS.values():
cur.execute('DROP TABLE IF EXISTS %s' % table_name)
table_fields = [ "%s %s" % table_field.listitems()[0] for table_field in TABLE_FIELDS ]
cur.execute('CREATE TABLE %s (%s)' % (table_name, ','.join(table_fields)))
エラーの詳細:
line 111, in <listcomp>
table_fields = [ "%s %s" % table_field.items()[0] for table_field in TABLE_FIELDS ]
TypeError: 'dict_items' object does not support indexing