mysql - why Python doesn't convert \n to newline when queried from Sqlite? -


I want to query with SQLite \ nAnd I hope the dragon will convert it to a new line but is not. And I too have \ nchanged \ n in the database but still can not be converted. For the row in the cursor

  cursor.exequote (Select the table from 'Select Test' ''): self.ui.textEdit.append (line [0]) # or print line [0]   

I also tried to do Unicode (line [0]) and not working. I am surprised that there is no easy solution for this in the web is not.

Neither convert SQLites nor characters in Python wires ( \ Except for a Python string is written in the source code). If you manage them correctly, then Newlines works properly:

  & gt; & Gt; & Gt; Import sqlite3 & gt; & Gt; & Gt; Db = sqlite3.connect (': memory:')> gt; & Gt; & Gt; C = db.cursor ()> gt; & Gt; & Gt; C.execute ('Create table T (X)')> gt; & Gt; & Gt; C.execute ("Insert T values ​​('x \ ny')") & gt; & Gt; & Gt; Insert in C.execute ("T values ​​('x \\ ny')")> gt; & Gt; & Gt; C.execute ("select from t") & gt; & Gt; & Gt; For line in C: ... print line [0] ... x y x \ ny    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -