sqlのインポートを修正、日本語テスト
This commit is contained in:
parent
4f78a54b2f
commit
f7f3e5d40b
1 changed files with 9 additions and 6 deletions
|
@ -2,6 +2,7 @@ import discord
|
|||
import os
|
||||
import json
|
||||
import psycopg2
|
||||
from psycopg2 import sql
|
||||
from datetime import datetime
|
||||
import asyncio
|
||||
import string
|
||||
|
@ -531,19 +532,19 @@ class DL():
|
|||
excel_file_path = self.export_dir_path + "pc_usage_history.xlsx"
|
||||
|
||||
# メインテーブルの列情報を取得(user_idを除く)
|
||||
cursor.execute(psycopg2.sql.SQL("SELECT * FROM {} LIMIT 0").format(psycopg2.sql.Identifier(main_table)))
|
||||
cursor.execute(sql.SQL("SELECT * FROM {} LIMIT 0").format(sql.Identifier(main_table)))
|
||||
main_columns = [desc[0] for desc in cursor.description if desc[0] != 'member_id']
|
||||
|
||||
# クエリを作成(列名を明確に指定)
|
||||
query = psycopg2.sql.SQL("""
|
||||
query = sql.SQL("""
|
||||
SELECT {main_columns}, {related_table}.name
|
||||
FROM {main_table}
|
||||
LEFT JOIN {related_table} ON {main_table}.member_id = {related_table}.member_id
|
||||
ORDER BY id
|
||||
""").format(
|
||||
main_columns=psycopg2.sql.SQL(', ').join([psycopg2.sql.SQL("{}.{}").format(psycopg2.sql.Identifier(main_table), psycopg2.sql.Identifier(col)) for col in main_columns]),
|
||||
main_table=psycopg2.sql.Identifier(main_table),
|
||||
related_table=psycopg2.sql.Identifier(related_table)
|
||||
main_columns=sql.SQL(', ').join([sql.SQL("{}.{}").format(sql.Identifier(main_table), sql.Identifier(col)) for col in main_columns]),
|
||||
main_table=sql.Identifier(main_table),
|
||||
related_table=sql.Identifier(related_table)
|
||||
)
|
||||
|
||||
cursor.execute(query)
|
||||
|
@ -787,7 +788,9 @@ async def devicereg(interaction: discord.Interaction):
|
|||
await interaction.response.send_message(":x: 内部エラーが発生しました。\nサーバーでエラーが発生しています。管理者に問い合わせてください。", ephemeral=True)
|
||||
|
||||
@tree.command(name="fstop", description="PCの使用を強制終了します。")
|
||||
async def fstop(interaction: discord.Interaction, pc_number: int, bot_about: str):
|
||||
async def fstop(interaction: discord.Interaction, PC番号: int, 理由: str):
|
||||
pc_number = PC番号
|
||||
bot_about = 理由
|
||||
force_stop = dislocker.force_stop(pc_number=pc_number, bot_about=bot_about)
|
||||
if force_stop["result"] == 0:
|
||||
await interaction.response.send_message(f":white_check_mark: PC {pc_number} の使用を強制終了しました。", ephemeral=True)
|
||||
|
|
Loading…
Reference in a new issue