"Go" removes the front and rear carriage return newline (newline) in the Sqlite3 database

Source: Internet
Author: User
Tags sqlite

original : http://www.blogjava.net/pts/archive/2013/06/10/400 ... Date : 2013-06-10

Transferred from: http://www.ityuedu.com/article/26601034478/;jsessionid=546A853CF3B219B9A242C75E039CB846

Recently used rails to make a small little website, the database is sqlite3, the database data is imported from an XML file, there are many leading carriage return and the end of the empty line, and the page will automatically replace the return of the display, the result is the content of the display of the end of the many more blank, The entire page looks very non-crab coordinated. Today, I decided to get rid of these useless carriage returns and break the line.

Not just a trim, soon into the SQLite command line interface, enter:

sqlite> Update jokes set Content=trim (content, ' \ n ');

Get it done.????? Refresh the page A look, I have a go, no Yes ~, SQLite do not recognize \ n, change to trim (content, ' \ R '), Trim (content, ' \ r \ n ') and trim (content, ' \n\r ') are not, brother is a lazy person, do not want to write code to solve, So Google, found someone to provide this solution:

x ' hh ' should work, where HH is hex digits. So if your file contained hex 0D type line breaks:update t SET essay_without_newlines = Replace (essay, X ' 0D ', ' ~ ');

In other words, SQLite can use the syntax of X ' HH ' to represent a character. Try the next X ' 0D ', no ... try x ' 0A 'again, just fine:

sqlite> Update jokes set Content=trim (content, X ' 0A ');

Journal a pen, there is no technical content. It is purely a memo, and I hope to be helpful to others.

Http://liang.eu/web-dev/trim-newlines-in-sqlite3

"Go" removes the front and rear carriage return newline (newline) in the Sqlite3 database

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.