-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #235 from pistachiostudio/d-uid-column
DBにDiscord UIDを追加してちょっと処理
- Loading branch information
Showing
5 changed files
with
90 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import sqlite3 | ||
|
||
# PUUIDの入力 | ||
puuid_input = input("タスクに追加するPUUIDを入力してください。") | ||
|
||
# Discord UIDの入力 | ||
try: | ||
discord_uid_input = int(input("プレイヤーのDiscord UIDを入力してください。整数です。")) | ||
except ValueError: | ||
print("Discord UIDは整数でなければなりません。") | ||
exit(1) | ||
|
||
# データベースへの接続 | ||
conn = sqlite3.connect("data/takohachi.db") | ||
cur = conn.cursor() | ||
|
||
# PUUIDの存在確認 | ||
cur.execute("SELECT COUNT(*) FROM val_puuids WHERE puuid = ?", (puuid_input,)) | ||
puuid_exists = cur.fetchone()[0] | ||
|
||
if puuid_exists == 0: | ||
print("指定されたPUUIDは存在しません。") | ||
conn.close() | ||
exit(1) | ||
|
||
# Discord UIDの挿入 | ||
cur.execute( | ||
""" | ||
UPDATE val_puuids | ||
SET d_uid = ? | ||
WHERE puuid = ? | ||
""", | ||
(discord_uid_input, puuid_input), | ||
) | ||
|
||
conn.commit() | ||
conn.close() | ||
|
||
print("done!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import sqlite3 | ||
|
||
# データベースへの接続 | ||
conn = sqlite3.connect("data/takohachi.db") | ||
cur = conn.cursor() | ||
|
||
# すべてのレコードを削除する | ||
cur.execute("DELETE FROM val_puuids") | ||
|
||
# 変更をコミット | ||
conn.commit() | ||
conn.close() | ||
|
||
print("すべてのレコードが削除されました。") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters