我尝试创建命令以发送到包含文件路径的Microsoft SQL Server,但我无法弄清楚如何发送包含单个反斜杠的字符串。
我正在创建这样的字符串:
>>> print(bulk_insert_string)
BULK INSERT my_table FROM C:\data_import_folder\my_import_filename.txt WITH (FIELDTERMINATOR = ';', ROWTERMINATOR = '\n')
然后如果我打印那个字符串,看起来我需要它:
>>> engine.execute(bulk_insert_string)
但是当我使用SQLAlchemy执行命令时,我收到了这个错误:
ProgrammingError: (pyodbc.ProgrammingError) ('42000', "[42000] [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Incorrect syntax near 'C:'. (102) (SQLExecDirectW)") [SQL: "BULK INSERT my_table FROM C:\\data_import_folder\\my_import_filename.txt WITH (FIELDTERMINATOR = ';', ROWTERMINATOR = '\\n')"]
export default Ember.Component.extend({
willRender: function() {
var tableRows = [];
var value = ['|', '-'];
var numRows = 20;
var numCells = 20;
for (var row = 1; row <= numRows; row++) {
var cellArr = []
for (var cell = 1; cell <= numCells; cell++) {
console.log('Math.round(Math.random()) ',Math.round(Math.random()));
cellArr[cell] = value[Math.round(Math.random())];
}
tableRows[row]=cellArr;
}
this.set('rows', {
'tableRows': tableRows,
});
}
});