问题描述
我正在尝试在python的Popen中使用tsql运行查询。我在套接字中执行此操作的方式很好,这是
export TSDVER=8.0
FSQL = tsql
export FREETDSCONF = .../file.conf (not real name)
User = "Domain/USER"
export DSQUERY="SERVER_NAME"
$FSQL -S $DSQUERY -U User -P "password"
因此,这提供了输入查询的选项,例如:
1> Select * FROM TABLE
2> go
然后显示结果。
在Popen中进行操作时,我有:
cmd = 'export TSDVER=8.0; FSQL = tsql; export FREETDSCONF = .../file.conf (not real name); User = "Domain/USER"; export DSQUERY="SERVER_NAME"; $FSQL -S $DSQUERY -U User -P "password"'
query = 'SELECT * FROM TABLE'
process = subprocess.POPEN(cmd,stdin=PIPE,stdout=PIPE,shell=True)
proc_stout = process.communicate(input=query)[0]
print(proc_stdout)
因此打印:
1> 2>
所以我想我可以登录数据库,但是没有查询通过。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)