31 lines
1.3 KiB
PowerShell
31 lines
1.3 KiB
PowerShell
# 仅导入报价模板表到 inquiry_robot(禁止动 jeecg-boot)
|
||
$ErrorActionPreference = 'Stop'
|
||
Get-Content 'E:\wwwroot\.env' | ForEach-Object {
|
||
$line = $_.Trim()
|
||
if (-not $line -or $line.StartsWith('#')) { return }
|
||
$i = $line.IndexOf('=')
|
||
if ($i -lt 1) { return }
|
||
$k = $line.Substring(0, $i).Trim()
|
||
$v = $line.Substring($i + 1).Trim().Trim('"')
|
||
Set-Item -Path "Env:$k" -Value $v
|
||
}
|
||
$mysql = 'C:\yutongda\tools\mysql-8.0.39-winx64\bin\mysql.exe'
|
||
$hostName = if ($env:MYSQL_HOST) { $env:MYSQL_HOST } else { '127.0.0.1' }
|
||
$tcp = New-Object System.Net.Sockets.TcpClient
|
||
try {
|
||
$null = $tcp.ConnectAsync('127.0.0.1', 3306).Wait(1000)
|
||
if ($tcp.Connected) { $hostName = '127.0.0.1' }
|
||
} catch {
|
||
} finally {
|
||
$tcp.Close()
|
||
}
|
||
Write-Host "import host=$hostName db=$env:MYSQL_DB"
|
||
$f = 'C:\Users\ytd_extdev_0903\incoming\inquiry_quote_template_v1.sql'
|
||
if (-not (Test-Path $f)) { throw "missing $f" }
|
||
Write-Host "import $f"
|
||
& $mysql -h $hostName -P 3306 -u $env:MYSQL_USER "--password=$env:MYSQL_PASSWORD" --default-character-set=utf8mb4 $env:MYSQL_DB -e "source $($f.Replace('\','/'))"
|
||
if ($LASTEXITCODE -ne 0) { throw "fail sql code=$LASTEXITCODE" }
|
||
Write-Host 'SQL_OK'
|
||
& $mysql -h $hostName -P 3306 -u $env:MYSQL_USER "--password=$env:MYSQL_PASSWORD" $env:MYSQL_DB -e "SHOW TABLES LIKE 'inq_quote_template%';"
|
||
Write-Host 'VERIFY_DONE'
|