DB名 test.db
table名 poke_imgs
tableの要素 (url,name)
このデータベースからurlで検索して、そのurlに対応するnameだけを抽出する方法がわかりません。
('https://cdn.discordapp.com/attachments/470628715290951680/495894918754074645/PokecordSpawn.jpg', 'Toucannon') ('https://cdn.discordapp.com/attachments/470628715290951680/495905792705429504/PokecordSpawn.jpg', 'Vanillish')
例えば
python
1latest_poke_url = "https://cdn.discordapp.com/attachments/470628715290951680/495905792705429504/PokecordSpawn.jpg" 2cursor.execute('SELECT * FROM poke_imgs WHERE url=?', (latest_poke_url, )) 3x = cursor.fetchone() 4print(x)
出力結果
python
1('https://cdn.discordapp.com/attachments/470628715290951680/495905792705429504/PokecordSpawn.jpg', 'Vanillish')
こうすると、検索はできるのですが、出力結果がNoneTypeでnameに対応するVanillish'の部分を取り出せません。
よろしくお願いします
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/09/30 13:03
2018/09/30 13:07
2018/09/30 13:11