• Как правильно проверить на соответствии строк?

    @eskotov Автор вопроса
    Спасибо за наводку займусь мануалом.
    На данный момент выгружаю в текст и ищу по тексту.
  • Все ли правильно при сборке контейнеров?

    @eskotov Автор вопроса
    ERROR: yaml.parser.ParserError: while parsing a block mapping
    in "./docker-compose.yml", line 5, column 3
    expected , but found ''
    in "./docker-compose.yml", line 64, column 5
    Написано 18 минут назад@Compolomus,
  • Все ли правильно при сборке контейнеров?

    @eskotov Автор вопроса
    ERROR: yaml.parser.ParserError: while parsing a block mapping
    in "./docker-compose.yml", line 5, column 3
    expected , but found ''
    in "./docker-compose.yml", line 64, column 5
  • Как Синтаксически правильно выполнить скрипт PowerShell?

    @eskotov Автор вопроса
    Желание Клиента для нас закон. Не важно что он может ошибаться. Я свое предложение озвучил но непрокатило.
  • Как при помощи ASP запустить *.bat на сервере?

    @eskotov Автор вопроса
    Илья, Конечно нет

    Просто скпипт индексации импорта в локалке что бы никого по правам не поднимать
  • Как при помощи ASP запустить *.bat на сервере?

    @eskotov Автор вопроса
    только незнаю как правильно синтаксически передать переменную
    что бы получилось так

    C:\Temp\script.bat переменная из формы
  • Как при помощи ASP запустить *.bat на сервере?

    @eskotov Автор вопроса
    примерно так

    using System;
    using System.Web;
    using System.Web.UI.WebControls;
    using System.Diagnostics;
    using System.ComponentModel;
    
    public partial class _Default : System.Web.UI.Page
    {
        protected void ButtonOk_Click(object sender, EventArgs e)
        {
            Process.Start("C:\\Temp\\script.bat");
        }
    }


    только незнаю как правильно синтаксически передать переменную
  • Как провильно передать CommandText?

    @eskotov Автор вопроса
    azarij,
    test.csv
    Opening the connection to DB to send data from this file...
    Connected to MySQL database localhost\curamed
    
    
    ServerThread      : 28
    DataSource        : localhost
    ConnectionTimeout : 15
    Database          : curamed
    UseCompression    : False
    State             : Open
    ServerVersion     : 5.5.5-10.1.37-MariaDB
    ConnectionString  : server=localhost;port=3306;user id=root;database=curamed;pooling=False
    IsPasswordExpired : False
    Site              : 
    Container         : 
    
    QUERY:
    LOAD DATA LOCAL INFILE 'C:\Temp\2\test.csv' INTO TABLE bga FIELDS ENCLOSED BY '"' TERMINATED BY ';' LINES TERMINATED BY '\n' IGNORE 1 LINES;
    CONNECTION right after open():
    ServerThread      : 
    DataSource        : localhost
    ConnectionTimeout : 15
    Database          : curamed
    UseCompression    : False
    State             : Closed
    ServerVersion     : 
    ConnectionString  : server=localhost;database=curamed;persistsecurityinfo=False;user id=root
    IsPasswordExpired : 
    Site              : 
    Container         : 
    
    Ausnahme beim Aufrufen von "ExecuteNonQuery" mit 0 Argument(en):  "Connection must be valid and open."
    In Zeile:42 Zeichen:1
    + $RowsInserted = $command.ExecuteNonQuery() # Execute command
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : InvalidOperationException
     
    False  inserted into database
    CONNECTION after command was sent:
    ServerThread      : 
    DataSource        : localhost
    ConnectionTimeout : 15
    Database          : curamed
    UseCompression    : False
    State             : Closed
    ServerVersion     : 
    ConnectionString  : server=localhost;database=curamed;persistsecurityinfo=False;user id=root
    IsPasswordExpired : 
    Site              : 
    Container         : 
    
    test1.csv
    Opening the connection to DB to send data from this file...
    Connected to MySQL database localhost\curamed
    ServerThread      : 29
    DataSource        : localhost
    ConnectionTimeout : 15
    Database          : curamed
    UseCompression    : False
    State             : Open
    ServerVersion     : 5.5.5-10.1.37-MariaDB
    ConnectionString  : server=localhost;port=3306;user id=root;database=curamed;pooling=False
    IsPasswordExpired : False
    Site              : 
    Container         : 
    
    QUERY:
    LOAD DATA LOCAL INFILE 'C:\Temp\2\test1.csv' INTO TABLE bga FIELDS ENCLOSED BY '"' TERMINATED BY ';' LINES TERMINATED BY '\n' IGNORE 1 LINES;
    CONNECTION right after open():
    ServerThread      : 
    DataSource        : localhost
    ConnectionTimeout : 15
    Database          : curamed
    UseCompression    : False
    State             : Closed
    ServerVersion     : 
    ConnectionString  : server=localhost;database=curamed;persistsecurityinfo=False;user id=root
    IsPasswordExpired : 
    Site              : 
    Container         : 
    
    Ausnahme beim Aufrufen von "ExecuteNonQuery" mit 0 Argument(en):  "Connection must be valid and open."
    In Zeile:42 Zeichen:1
    + $RowsInserted = $command.ExecuteNonQuery() # Execute command
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : InvalidOperationException
     
    False  inserted into database
    CONNECTION after command was sent:
    ServerThread      : 
    DataSource        : localhost
    ConnectionTimeout : 15
    Database          : curamed
    UseCompression    : False
    State             : Closed
    ServerVersion     : 
    ConnectionString  : server=localhost;database=curamed;persistsecurityinfo=False;user id=root
    IsPasswordExpired : 
    Site              : 
    Container         : 
    
    Closing connection to DB
    
    
    
    PS C:\Windows\system32>
  • Как провильно передать CommandText?

    @eskotov Автор вопроса
    azarij,
    Connected to MySQL database localhost\curamed
    
    
    ServerThread      : 14
    DataSource        : localhost
    ConnectionTimeout : 15
    Database          : curamed
    UseCompression    : False
    State             : Open
    ServerVersion     : 8.0.14
    ConnectionString  : server=localhost;port=3306;user id=root;database=curamed;pooling=False
    IsPasswordExpired : False
    Site              : 
    Container         : 
    
    test.csv
    QUERY:
    LOAD DATA LOCAL INFILE 'C:\Temp\2\test.csv' INTO TABLE bga FIELDS ENCLOSED BY '"' TERMINATED BY ';' LINES TERMINATED BY '\n' IGNORE 1 LINES;
    CONNECTION:
    ServerThread      : 39
    DataSource        : localhost
    ConnectionTimeout : 15
    Database          : curamed
    UseCompression    : False
    State             : Closed
    ServerVersion     : 8.0.14
    ConnectionString  : server=localhost;database=curamed;persistsecurityinfo=False;user id=root
    IsPasswordExpired : False
    Site              : 
    Container         : 
    
    Ausnahme beim Aufrufen von "ExecuteNonQuery" mit 0 Argument(en):  "Connection must be valid and open."
    In Zeile:42 Zeichen:1
    + $RowsInserted = $command.ExecuteNonQuery() # Execute command
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : InvalidOperationException
     
    False  inserted into database
    test1.csv
    QUERY:
    LOAD DATA LOCAL INFILE 'C:\Temp\2\test1.csv' INTO TABLE bga FIELDS ENCLOSED BY '"' TERMINATED BY ';' LINES TERMINATED BY '\n' IGNORE 1 LINES;
    CONNECTION:
    ServerThread      : 39
    DataSource        : localhost
    ConnectionTimeout : 15
    Database          : curamed
    UseCompression    : False
    State             : Closed
    ServerVersion     : 8.0.14
    ConnectionString  : server=localhost;database=curamed;persistsecurityinfo=False;user id=root
    IsPasswordExpired : False
    Site              : 
    Container         : 
    
    Ausnahme beim Aufrufen von "ExecuteNonQuery" mit 0 Argument(en):  "Connection must be valid and open."
    In Zeile:42 Zeichen:1
    + $RowsInserted = $command.ExecuteNonQuery() # Execute command
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : InvalidOperationException
     
    False  inserted into database
    
    
    
    PS C:\Windows\system32>
  • Как провильно передать CommandText?

    @eskotov Автор вопроса
    azarij, ok

    Connected to MySQL database localhost\curamed
    
    
    ServerThread      : 35
    DataSource        : localhost
    ConnectionTimeout : 15
    Database          : curamed
    UseCompression    : False
    State             : Open
    ServerVersion     : 8.0.14
    ConnectionString  : server=localhost;port=3306;user id=root;database=curamed;pooling=False
    IsPasswordExpired : False
    Site              : 
    Container         : 
    
    test.csv
    LOAD DATA LOCAL INFILE 'C:\Temp\2\test.csv' INTO TABLE bga FIELDS ENCLOSED BY '"' TERMINATED BY ';' LINES TERMINATED BY '\n' IGNORE 1 LINES;
    Ausnahme beim Aufrufen von "ExecuteNonQuery" mit 0 Argument(en):  "Connection must be valid and open."
    In Zeile:42 Zeichen:1
    + $RowsInserted = $command.ExecuteNonQuery() # Execute command
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : InvalidOperationException
     
    False  inserted into database
    test1.csv
    LOAD DATA LOCAL INFILE 'C:\Temp\2\test1.csv' INTO TABLE bga FIELDS ENCLOSED BY '"' TERMINATED BY ';' LINES TERMINATED BY '\n' IGNORE 1 LINES;
    Ausnahme beim Aufrufen von "ExecuteNonQuery" mit 0 Argument(en):  "Connection must be valid and open."
    In Zeile:42 Zeichen:1
    + $RowsInserted = $command.ExecuteNonQuery() # Execute command
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : InvalidOperationException
     
    False  inserted into database
    
    
    
    PS C:\Windows\system32>
  • Как провильно передать CommandText?

    @eskotov Автор вопроса
    azarij, Выкинул все и оставил самое необходимое.

    Убрал обратные ковычки, добавил еще один запрос для подстраховки.
    Возможно команнда "LOAD DATA LOCAL" была заблокированна.

    Получилось примерно следующее:

    $dbusername = 'root' 
    $dbpassword = '123456' 
    $dbname = 'curamed' 
    $MySQLHost = 'localhost' 
    $dir = 'C:\Temp\1'
    $dir2 = 'C:\Temp\2'
    [void][system.reflection.Assembly]::LoadWithPartialName("MySql.Data")
    $connStr ="server=localhost;database=" + $dbname + ";Persist Security Info=false;user id=" + $dbusername + ";pwd=" + $dbpassword + ";"
    $conn = New-Object MySql.Data.MySqlClient.MySqlConnection($connStr)
    $conn.Open()
    $cmd = New-Object MySql.Data.MySqlClient.MySqlCommand
    $cmd.Connection  = $conn
    
    Foreach ($i in ls -name $dir\*.csv)
    {
    	Write-Host "$i"
    	$file_content = Get-Content "$dir\$i";
    	[System.IO.File]::WriteAllLines("$dir2\$i", $file_content);
    	#Remove-Item "$dir\$i"
    # So, to insert records into a table 
        $cmd.CommantText ="SET @@GLOBAL. local_infile := 1;
        $cmd.CommandText ="LOAD DATA LOCAL INFILE '$dir2\$i' INTO TABLE bga FIELDS ENCLOSED BY '`"' TERMINATED BY ';' LINES TERMINATED BY '\n' IGNORE 1 LINES;"
        $cmd.ExecuteNonQuery()
        Write-Host  " inserted into database"
    }


    И ошибка :

    In Zeile:22 Zeichen:24
    +     $cmd.CommandText ="LOAD DATA LOCAL INFILE '$dir2\$i' INTO TABLE b ...
    +                        ~~~~
    Unerwartetes Token "LOAD" in Ausdruck oder Anweisung.
    In Zeile:24 Zeichen:19
    +     Write-Host  " inserted into database"
    +                   ~~~~~~~~
    Unerwartetes Token "inserted" in Ausdruck oder Anweisung.
    In Zeile:24 Zeichen:41
    +     Write-Host  " inserted into database"
    +                                         ~
    Die Zeichenfolge hat kein Abschlusszeichen: ".
    In Zeile:15 Zeichen:1
    + {
    + ~
    Die schließende "}" fehlt im Anweisungsblock oder der Typdefinition.
        + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
        + FullyQualifiedErrorId : UnexpectedToken
     
    
    PS C:\Windows\system32>
  • Как провильно передать CommandText?

    @eskotov Автор вопроса
    azarij,
    Connected to MySQL database localhost\curamed
    
    
    ServerThread      : 10
    DataSource        : localhost
    ConnectionTimeout : 15
    Database          : curamed
    UseCompression    : False
    State             : Open
    ServerVersion     : 8.0.14
    ConnectionString  : server=localhost;port=3306;user id=root;database=curamed;pooling=False
    IsPasswordExpired : False
    Site              : 
    Container         : 
    
    test.csv
    LOAD DATA LOCAL INFILE 'C:\Temp\2\test.csv' INTO TABLE ga FIELDS ENCLOSED BY '"' TERMINATED BY ';' LINES TERMINATED BY '\n' IGNORE 1 LINES;
    Ausnahme beim Aufrufen von "ExecuteNonQuery" mit 0 Argument(en):  "Fatal error encountered during command execution."
    In Zeile:42 Zeichen:3
    +   $RowsInserted = $command.ExecuteNonQuery()        # Execute command
    +   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : MySqlException
     
    False  inserted into database
    test1.csv
    LOAD DATA LOCAL INFILE 'C:\Temp\2\test1.csv' INTO TABLE ga FIELDS ENCLOSED BY '"' TERMINATED BY ';' LINES TERMINATED BY '\n' IGNORE 1 LINES;
    Ausnahme beim Aufrufen von "ExecuteNonQuery" mit 0 Argument(en):  "Connection must be valid and open."
    In Zeile:42 Zeichen:3
    +   $RowsInserted = $command.ExecuteNonQuery()        # Execute command
    +   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : InvalidOperationException
     
    False  inserted into database
    
    
    
    PS C:\Windows\system32>
  • Как провильно передать CommandText?

    @eskotov Автор вопроса
    azarij, 2 Ошибки одна незначительная

    2 с SQL

    Log : Die Benennung "Log" wurde nicht als Name eines Cmdlet, einer Funktion, einer Skriptdatei oder eines ausführbaren Programms erkannt. Überprüfen 
    Sie die Schreibweise des Namens, oder ob der Pfad korrekt ist (sofern enthalten), und wiederholen Sie den Vorgang.
    In Zeile:29 Zeichen:5
    +     Log "Connected to MySQL database $MySQLHost\$database"
    +     ~~~
        + CategoryInfo          : ObjectNotFound: (Log:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException


    Ausnahme beim Aufrufen von "ExecuteNonQuery" mit 0 Argument(en):  "You have an error in your SQL syntax; check the manual that corresponds to your 
    MySQL server version for the right syntax to use near 'ga FIELDS ENCLOSED BY '"' TERMINATED BY ';' LINES TERMINATED BY '\n' IGNORE 1 L' at line 1"
    In Zeile:42 Zeichen:3
    +   $RowsInserted = $command.ExecuteNonQuery()        # Execute command
    +   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : MySqlException
  • Как провильно передать CommandText?

    @eskotov Автор вопроса
    Переделал по примеру но наверное что то неучел так как нет соединения с базой

    # Connection Variables 
    $user = 'root' 
    $pass = '123456' 
    $database = 'curamed' 
    $MySQLHost = 'localhost' 
    $dir = 'C:\Temp\1'
    $dir2 = 'C:\Temp\2'
    
    function Connect-MySQL([string]$user,[string]$pass,[string]$MySQLHost,[string]$database) { 
      # Load MySQL .NET Connector Objects 
      [void][system.reflection.Assembly]::LoadWithPartialName("MySql.Data") 
    
      # Open Connection 
      $connStr = "server=" + $MySQLHost + ";port=3306;uid=" + $user + ";pwd=" + $pass + ";database="+$database+";Pooling=FALSE" 
      $conn = New-Object MySql.Data.MySqlClient.MySqlConnection($connStr) 
     try {
            $conn = New-Object MySql.Data.MySqlClient.MySqlConnection($connStr) 
            $conn.Open()
        } catch [System.Management.Automation.PSArgumentException] {
            Log "Unable to connect to MySQL server, do you have the MySQL connector installed..?"
            Log $_
            Exit
        } catch {
            Log "Unable to connect to MySQL server..."
            Log $_.Exception.GetType().FullName
            Log $_.Exception.Message
            exit
        }
        Log "Connected to MySQL database $MySQLHost\$database"
    
        return $conn 
    
    } 
    
    function Disconnect-MySQL($conn) {
      $conn.Close()
    }
    
    function Execute-MySQLNonQuery($conn, [string]$query) { 
      $command = $conn.CreateCommand()                  # Create command object
      $command.CommandText = $query                     # Load query into object
      $RowsInserted = $command.ExecuteNonQuery()        # Execute command
      $command.Dispose()                                # Dispose of command object
      if ($RowsInserted) { 
        return $RowInserted 
      } else { 
        return $false 
      } 
    } 
    
    foreach ($i in ls -name $dir\*.csv)
    {
    	Write-Host "$i"
    	$file_content = Get-Content "$dir\$i";
    	[System.IO.File]::WriteAllLines("$dir2\$i", $file_content);
    	Remove-Item "$dir\$i"
    # So, to insert records into a table 
        $query = "LOAD DATA LOCAL INFILE '$dir2\$i' INTO TABLE `bga` FIELDS ENCLOSED BY '`"' TERMINATED BY ';' LINES TERMINATED BY '\n' IGNORE 1 LINES;"
        $Rows = Execute-MySQLNonQuery $conn $query 
        Write-Host $Rows " inserted into database"
    }
  • Как провильно передать CommandText?

    @eskotov Автор вопроса
    На данный момент нашел статью с примерами надо разбираться
    https://vwiki.co.uk/MySQL_and_PowerShell
  • Как провильно передать CommandText?

    @eskotov Автор вопроса
    Текст запроса был сгенерирован HeidiSQL и опробириван в консоли

    Парсер больше не ругается, но походу так оно тоже не работает.
    Выдает следующую ошибку:

    Die Eigenschaft "CommandText" wurde für dieses Objekt nicht gefunden. Vergewissern Sie sich, dass die Eigenschaft vorhanden ist und festgelegt werden kann.
    In Zeile:21 Zeichen:2
    +     $conn.CommandText = "LOAD DATA LOCAL INFILE '$dir2\$i' INTO TABLE ...
    +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : PropertyAssignmentException
     
    Fehler beim Aufrufen der Methode, da [MySql.Data.MySqlClient.MySqlConnection] keine Methode mit dem Namen "ExecuteNonQuery" enthält.
    In Zeile:23 Zeichen:5
    +     $conn.ExecuteNonQuery()
    +     ~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : MethodNotFound
  • Не работает скрипт. Где ошибка?

    @eskotov Автор вопроса
    При попытке запустить скрипт выводит примерно следующее

    In Zeile:20 Zeichen:127
    + ... TABLE `curamed`.`bga` FIELDS ENCLOSED BY '\"' TERMINATED BY ';' LINES ...
    +                                                 ~~~~~~~~~~~~~~~~~
    Unerwartetes Token "' TERMINATED BY '" in Ausdruck oder Anweisung.
    In Zeile:20 Zeichen:170
    + ... D BY '\"' TERMINATED BY ';' LINES TERMINATED BY '\n' IGNORE 1 LINES;"
    +                                                        ~~~~~~~~~~~~~~~~~~
    Die Zeichenfolge hat kein Abschlusszeichen: '.
    In Zeile:20 Zeichen:168
    + ... D BY '\"' TERMINATED BY ';' LINES TERMINATED BY '\n' IGNORE 1 LINES;"
    +                                                      ~~~~~~~~~~~~~~~~~~~~
    Unerwartetes Token "\n' IGNORE 1 LINES;"
       
       $cmd.ExecuteNonQuery() 
    }
    $conn.Close()" in Ausdruck oder Anweisung.
    In Zeile:17 Zeichen:26
    + ForEach($File in $Files) {
    +                          ~
    Die schließende "}" fehlt im Anweisungsblock oder der Typdefinition.
        + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
        + FullyQualifiedErrorId : UnexpectedToken