SQL server write script:
sqlCommand = "INSERT INTO ...
ds = DatabaseDataSource(DatabaseDataSourceSettings("System.Data.SqlClient","Server=xxx;Database=xxx;UID=xxx;PWD=xxx",sqlCommand))
#execute by creating a temp table with db source, then drop table
newDataTable = Document.Data.Tables.Add("temp",ds)
Document.Data.Tables.Remove(newDataTable)
然而,此方法略有延迟。是否可以在不创建临时表的情况下执行此操作?
答案 0 :(得分:3)
以为我会在很久以前回答我自己的问题。使用这个简单的脚本可以避免Spotfire库并使用.NET System.Data.SqlClient更快地执行:
import clr, datetime
clr.AddReference('System.Data')
from System.Data import SqlClient
from System import Threading, DateTime
sql = "INSERT INTO ...."
conn = SqlClient.SqlConnection("Server=;Database=;UID=;PWD=")
conn.Open()
cmd = SqlClient.SqlCommand(sql, conn)
exe = cmd.ExecuteReader()
exe.Close()
conn.Close()