troubleshoot sqlcmd issues

This commit is contained in:
yitam 2017-05-02 16:42:23 -07:00
parent f846fa68c9
commit 9b930973f2
2 changed files with 6 additions and 7 deletions

View file

@ -153,11 +153,11 @@ Set Result PDO::ATTR_SERVER_INFO :
SQLSTATE\[IMSSP\]: A read-only attribute was designated on the PDO object.
Get Result PDO::ATTR_SERVER_INFO :
array\(3\) {
\["CurrentdatabaseName"\]=>
\["CurrentDatabase"\]=>
string\([0-9]*\) ".*"
\["SQLServerVersion"\]=>
string\(10\) "[0-9]{2}.[0-9]{2}.[0-9]{4}"
\["SQLserver"\]=>
\["SQLServerName"\]=>
string\([0-9]*\) ".*"
}

View file

@ -28,17 +28,16 @@ def executeSQLscriptUnix(sqlfile, conn_options, dbname):
# This is a workaround because sqlcmd in Unix does not support -v option for variables.
# It inserts setvar dbname into the beginning of a temp .sql file
tmpFileName = sqlfile[0:-4] + '_tmp.sql'
# redirect_string = '(echo :setvar dbname {0}) > {2}; cat {1} >> {2}; cat {2}; '
redirect_string = '(echo :setvar dbname {0}) > {2}; cat {1} >> {2}; '
sqlcmd = 'sqlcmd ' + conn_options + ' -i ' + tmpFileName
# this step seems necessary in travis CI
show_cmd = 'sqlcmd ' + conn_options + ' -Q \"select @@Version\" '
executeCommmand(show_cmd)
# inst_command = redirect_string.format(dbname, sqlfile, tmpFileName) + sqlcmd
inst_command = redirect_string.format(dbname, sqlfile, tmpFileName)
inst_command = redirect_string.format(dbname, sqlfile, tmpFileName) + sqlcmd
#inst_command = redirect_string.format(dbname, sqlfile, tmpFileName)
executeCommmand(inst_command)
executeCommmand(sqlcmd)
#executeCommmand(sqlcmd)
os.remove(tmpFileName)