[英]append lines with “\LF” into one line, until finds “\CR\LF”?
[英]Preserve CR LF(New Lines) On Insert Into SQL Server
我正在尝试将数据插入sql server varchar(max)字段并保留换行符。 这些是地址,换行符对于解析地址数据至关重要。 我在一个窗口中运行输出以查看结果是什么,并且在命令行中保留了换行符,但未在插入SQL Server时进行换行
for dirpath, subdirs, files in os.walk(process):
for file in files:
dateadded = datetime.datetime.now()
if file.endswith(('.dbf', '.DBF')):
dbflocation = os.path.abspath(os.path.join(dirpath, file)).lower()
if dbflocation.__contains__("\\xxx.dbf"):
table = DBF(dbflocation, lowernames=True, char_decode_errors='ignore')
for record in table.records or table.deleted:
rec1 = record['key1']
rec2 = str(record['xxx1'])
rec3 = str(record['xxx2'])
rec4 = record['xxx3']
rec5 = str(record['xxx4'])
rec6 = record['address1'] #address to parse
# if table.delete == True:
# rec42 = 1
cursor.execute(
"insert into tblepiqclaims(key1,xxx1,xxx2,xxx3,xxx4,address1) values(?,?,?,?,?,?)",
rec1, rec2, rec3, rec4, rec5, rec6)
print rec6
cnxn.commit()
您需要在varchar字段中定义转义字符。
例如:
输入='1#2#3'
打印input.split('#')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.