1
0
mirror of https://github.com/ManyakRus/starter.git synced 2025-11-28 23:20:10 +02:00

сделал RawMultipleSQL()

This commit is contained in:
Nikitin Aleksandr
2024-03-25 17:59:54 +03:00
parent efa1ece363
commit 74736b68fb
2 changed files with 90 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ package postgres_pgx
import (
"errors"
"testing"
"time"
//log "github.com/sirupsen/logrus"
@@ -111,3 +112,39 @@ func TestConnect_WithApplicationName_err(t *testing.T) {
CloseConnection()
}
func TestRawMultipleSQL(t *testing.T) {
config_main.LoadEnv()
GetConnection()
defer CloseConnection()
TimeStart := time.Now()
TextSQL := `
drop table if exists temp_TestRawMultipleSQL2;
CREATE TEMPORARY TABLE temp_TestRawMultipleSQL2 (id int);
insert into temp_TestRawMultipleSQL2
select 1;
SELECT * FROM temp_TestRawMultipleSQL2
`
//TextSQL := "SELECT 1; SELECT 2"
Rows, err := RawMultipleSQL(Conn, TextSQL)
if err != nil {
t.Error("TestRawMultipleSQL() error: ", err)
}
if Rows == nil {
}
Otvet := 0
for Rows.Next() {
err := Rows.Scan(&Otvet)
if err != nil {
t.Error("TestRawMultipleSQL() Scan() error: ", err)
}
}
t.Log("Прошло время: ", time.Since(TimeStart))
}