Здравствуйте и спасибо, что нашли время, чтобы прочитать это.Я хочу извлечь большое количество текста из одной базы данных в другую.Проблема в том, что когда я читаю текст из базы данных, он содержит много символов "\ N", \ n ".Я был бы очень признателен, если бы кто-то мог указать мне правильное направление или сказать, что именно здесь происходит и почему команда fetchall ведет себя так ...
Заранее спасибо!
Пример текста в ТАБЛИЦЕ: наши данные (из которых я хочу прочитать):
Пример текста в ТАБЛИЦЕ product_d Iпишу:
Это код, который я использую:
import sqlite3
database_path = "E:/Thesis stuff/Python/database/"
conn = sqlite3.connect(database_path + 'test2.db')
c = conn.cursor()
current_number = 0
# creates the table to which the descriptions go
c.execute("CREATE TABLE IF NOT EXISTS product_d (product_description TEXT)")
conn.commit()
c.execute("SELECT description FROM ourdata")
text_to_format = c.fetchall()
print(text_to_format[0])
text_list = []
# make a list of the descriptions
for text in text_to_format:
text = str(text)
text_list.append(text)
# put all the elements of the list into the new table
for item in text_list:
c.execute("INSERT INTO product_d (product_description) VALUES (?)", (text_list[current_number],))
print("at number " + str(current_number))
current_number += 1
conn.commit()
c.close()
conn.close()