41 lines
1.2 KiB
PowerShell
41 lines
1.2 KiB
PowerShell
|
|
param(
|
||
|
|
[string]$HostName = "127.0.0.1",
|
||
|
|
[int]$Port = 3306,
|
||
|
|
[string]$User = "root",
|
||
|
|
[string]$Password = "",
|
||
|
|
[string]$DatabaseName = "medical_consultation_agent",
|
||
|
|
[string]$MysqlExe = "mysql"
|
||
|
|
)
|
||
|
|
|
||
|
|
$ErrorActionPreference = "Stop"
|
||
|
|
|
||
|
|
if ([string]::IsNullOrWhiteSpace($Password)) {
|
||
|
|
$securePassword = Read-Host "MySQL password for $User@$HostName" -AsSecureString
|
||
|
|
$bstr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($securePassword)
|
||
|
|
try {
|
||
|
|
$Password = [Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr)
|
||
|
|
}
|
||
|
|
finally {
|
||
|
|
[Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
$env:MYSQL_PWD = $Password
|
||
|
|
|
||
|
|
try {
|
||
|
|
& $MysqlExe -h $HostName -P $Port -u $User --default-character-set=utf8mb4 -D $DatabaseName -e @"
|
||
|
|
SELECT TABLE_NAME, TABLE_COMMENT
|
||
|
|
FROM information_schema.tables
|
||
|
|
WHERE table_schema = '$DatabaseName'
|
||
|
|
ORDER BY TABLE_NAME;
|
||
|
|
SELECT COUNT(*) AS case_count FROM cases;
|
||
|
|
SELECT COUNT(*) AS exam_item_count FROM case_exam_items;
|
||
|
|
SELECT COUNT(*) AS prompt_template_count FROM prompt_templates;
|
||
|
|
SELECT COUNT(*) AS rubric_template_count FROM rubric_templates;
|
||
|
|
SELECT COUNT(*) AS knowledge_chunk_count FROM knowledge_chunks;
|
||
|
|
"@
|
||
|
|
}
|
||
|
|
finally {
|
||
|
|
Remove-Item Env:\MYSQL_PWD -ErrorAction SilentlyContinue
|
||
|
|
}
|