mattn / go-adodb

Microsoft ActiveX Object DataBase driver for go that using exp/sql
http://mattn.kaoriya.net/
MIT License
142 stars 36 forks source link

do not support command timeout attribute? #41

Open anhuizf1 opened 5 years ago

anhuizf1 commented 5 years ago

rv, err = oleutil.PutProperty(s, "CommandTimeout", 1800) if err != nil { return nil, err }

1800 as parameter from outer

mattn commented 5 years ago

Please put your code to reproduce here.

anhuizf1 commented 5 years ago

I have a very slow SQL that I'm calling, that puts a lot of data together. I'd like to set the Command Timeout to 1800 seconds, but I don't know how to write code.

yzj0911 commented 3 years ago

var conf []string var db *sql.DB var err error conf = append(conf, "Provider=SQLOLEDB") conf = append(conf, "Data Source=(local)") // sqlserver IP 和 服务器名称 conf = append(conf, "Initial Catalog=master") // 数据库名 conf = append(conf, "user id=sa") // 登陆用户名 conf = append(conf, "password=Howlink@1401") // 登陆密码 conf = append(conf, "keepAlive=0") conf = append(conf, "connection timeout=0") fmt.Println(strings.Join(conf, ";")) db, err = sql.Open("adodb", strings.Join(conf, ";")) if err != nil { fmt.Println("sql open:", err) return } // 执行SQL语句 fmt.Println("start") fmt.Println(time.Now()) fmt.Println("=====1=====") fmt.Println(time.Now())

res, err := db.Query("WAITFOR DELAY '00:02'")
if err != nil {
    fmt.Println(err)
    fmt.Println(time.Now())
    return
}
fmt.Println(res)
yzj0911 commented 3 years ago

image How to set timeout