file

How to execute an .sql file in pymssql

微笑、不失礼 提交于 2021-02-08 13:12:13
问题 I'm trying to execute an sql file in python using pymssql, this file contains a BEGIN TRANSACTION, a COMMIT TRANSACTION and an END, and some safety nets before and after. I'm trying to open the file in memory and execute the content: file = open(options.sqlFile, 'r') sqlFileContents = file.read() file.close() cursor.execute(sqlFileContents) conn.commit() But it's returning me errors: pymssql.ProgrammingError: (102, "Incorrect syntax near 'GO'.DB-Lib error message 102, severity 15:\nGeneral

string argument expected, got 'bytes' in buffer.write

限于喜欢 提交于 2021-02-08 13:09:30
问题 I have this: from io import StringIO buffer = StringIO() latest_file = 'C:\\Users\\miguel.santos\\Desktop\\meo_snapshots\\Snapshot_14.jpg' buffer.write(open(latest_file,'rb').read()) TypeError: string argument expected, got 'bytes' Any ideas on how to solve? 回答1: io.StringIO is for unicode text, its counterpart for bytes is io.BytesIO . As your undelying file is a binary jpg, you really should use the latter: from io import BytesIO buffer = BytesIO() latest_file = 'C:\\Users\\miguel.santos\

string argument expected, got 'bytes' in buffer.write

吃可爱长大的小学妹 提交于 2021-02-08 13:08:33
问题 I have this: from io import StringIO buffer = StringIO() latest_file = 'C:\\Users\\miguel.santos\\Desktop\\meo_snapshots\\Snapshot_14.jpg' buffer.write(open(latest_file,'rb').read()) TypeError: string argument expected, got 'bytes' Any ideas on how to solve? 回答1: io.StringIO is for unicode text, its counterpart for bytes is io.BytesIO . As your undelying file is a binary jpg, you really should use the latter: from io import BytesIO buffer = BytesIO() latest_file = 'C:\\Users\\miguel.santos\

UCMA Send File & File Transfer Sample

烈酒焚心 提交于 2021-02-08 13:08:15
问题 There are no samples using for UCMA to send file from applicationendpoint to userendpoint or vice versa. I've tried below sample but it didn't work. See code and error: if (e.State == MediaFlowState.Active) { byte[] fileBytes = null; using (FileStream fs = File.OpenRead(_fileToSend)) { fileBytes = new byte[fs.Length]; fs.Read(fileBytes, 0, fileBytes.Length); } ContentType ct = new ContentType("text/x-msmsgsinvite"); ct.CharSet = "UTF-8"; StringBuilder sb = new StringBuilder(); sb.Append(

string argument expected, got 'bytes' in buffer.write

╄→гoц情女王★ 提交于 2021-02-08 13:07:47
问题 I have this: from io import StringIO buffer = StringIO() latest_file = 'C:\\Users\\miguel.santos\\Desktop\\meo_snapshots\\Snapshot_14.jpg' buffer.write(open(latest_file,'rb').read()) TypeError: string argument expected, got 'bytes' Any ideas on how to solve? 回答1: io.StringIO is for unicode text, its counterpart for bytes is io.BytesIO . As your undelying file is a binary jpg, you really should use the latter: from io import BytesIO buffer = BytesIO() latest_file = 'C:\\Users\\miguel.santos\

UCMA Send File & File Transfer Sample

一个人想着一个人 提交于 2021-02-08 13:06:15
问题 There are no samples using for UCMA to send file from applicationendpoint to userendpoint or vice versa. I've tried below sample but it didn't work. See code and error: if (e.State == MediaFlowState.Active) { byte[] fileBytes = null; using (FileStream fs = File.OpenRead(_fileToSend)) { fileBytes = new byte[fs.Length]; fs.Read(fileBytes, 0, fileBytes.Length); } ContentType ct = new ContentType("text/x-msmsgsinvite"); ct.CharSet = "UTF-8"; StringBuilder sb = new StringBuilder(); sb.Append(

UCMA Send File & File Transfer Sample

北城以北 提交于 2021-02-08 13:06:06
问题 There are no samples using for UCMA to send file from applicationendpoint to userendpoint or vice versa. I've tried below sample but it didn't work. See code and error: if (e.State == MediaFlowState.Active) { byte[] fileBytes = null; using (FileStream fs = File.OpenRead(_fileToSend)) { fileBytes = new byte[fs.Length]; fs.Read(fileBytes, 0, fileBytes.Length); } ContentType ct = new ContentType("text/x-msmsgsinvite"); ct.CharSet = "UTF-8"; StringBuilder sb = new StringBuilder(); sb.Append(

UCMA Send File & File Transfer Sample

青春壹個敷衍的年華 提交于 2021-02-08 13:05:57
问题 There are no samples using for UCMA to send file from applicationendpoint to userendpoint or vice versa. I've tried below sample but it didn't work. See code and error: if (e.State == MediaFlowState.Active) { byte[] fileBytes = null; using (FileStream fs = File.OpenRead(_fileToSend)) { fileBytes = new byte[fs.Length]; fs.Read(fileBytes, 0, fileBytes.Length); } ContentType ct = new ContentType("text/x-msmsgsinvite"); ct.CharSet = "UTF-8"; StringBuilder sb = new StringBuilder(); sb.Append(

UCMA Send File & File Transfer Sample

☆樱花仙子☆ 提交于 2021-02-08 13:05:25
问题 There are no samples using for UCMA to send file from applicationendpoint to userendpoint or vice versa. I've tried below sample but it didn't work. See code and error: if (e.State == MediaFlowState.Active) { byte[] fileBytes = null; using (FileStream fs = File.OpenRead(_fileToSend)) { fileBytes = new byte[fs.Length]; fs.Read(fileBytes, 0, fileBytes.Length); } ContentType ct = new ContentType("text/x-msmsgsinvite"); ct.CharSet = "UTF-8"; StringBuilder sb = new StringBuilder(); sb.Append(

How to execute an .sql file in pymssql

淺唱寂寞╮ 提交于 2021-02-08 13:05:15
问题 I'm trying to execute an sql file in python using pymssql, this file contains a BEGIN TRANSACTION, a COMMIT TRANSACTION and an END, and some safety nets before and after. I'm trying to open the file in memory and execute the content: file = open(options.sqlFile, 'r') sqlFileContents = file.read() file.close() cursor.execute(sqlFileContents) conn.commit() But it's returning me errors: pymssql.ProgrammingError: (102, "Incorrect syntax near 'GO'.DB-Lib error message 102, severity 15:\nGeneral