While inserting a document in mongodb, one of the variables in the object that I am trying to insert contains curly braces '{abc123}' as a part of value.
This is causing the inserts to fail. Any way around it?
The simplest way is to use both double and single quotes: "'abc123'". Double quotes will mark the JavaScript string and single quotes will be handled as literal values, as if it was escaped with backslash.
Related
Have a current data set that has a column named vendor and it is identified as string.
When Eclipse export the results, it is not surrounding this field in double quotes as it sees only numbers. This leads to Excel dropping the leading zeros.
Is there a way to make sure all string fields get surrounded by double quotes?
I am new to postgresql and just starting to use it. I am trying to load a file into a table and facing some issues.
Sample data - the file file1.RPT contains data in the below format
"Bharath"|Kumar|Krishnan
abc"|def|ghi
qwerty|asdfgh|lkjhg
Below is the load script that is used
LOAD CSV
INTO table1
....
WITH truncate,
fields optionally enclosed by '"',
fields escaped by '"'
fields terminated by '|'
....
However, the above script is not working and is not loading any data into the table. I am not sure whats the issue here. My understanding is that first row data has to be successfully loaded (since I have given optionally enclosed by) and the second row also must be loaded (since I am trying to escape the double quote).
Request help in getting the same rectified.
Thank you.
We cannot escape and optionally quote the same character. If the double-quote will be part of the data, then it can be ignored using field not enclosed option. The default option is field optionally enclosed by double-quote.
Apparently, you're not escaping the quote in the second row, because either you must use a backslash (or another quoting character) before:
abc\"|def|ghi
or you should enclose the entire line with quote
another alternative is to accept to have quotes in the first field, then you should use the following:
fields not enclosed
in your load script
I want to give name "http://192.168.1.2/abc/xyz_values" to a table in SQLite.
I am creating the table dynamically. How can i achieve this, as SQLite is not allowing me to create a table with this name?
Any help will be appreciated.
use square brackets [http://192.168.1.2/abc/xyz_values] when creating your table
Choose a different name for your table. It is not possible.
Why does the name have to be like that in the first place? It sounds a little dodgy...
There are three methods to create identifiers with special characters: double quotes, backticks, and square brackets.
Double quotes are standard SQL, while backticks and square brackets are supported only for compatibility with MySQL and SQL Server, so it's recommended to use the former:
CREATE TABLE "http://192.168.1.2/abc/xyz_values"(...)
Double quotes and backticks that occur inside the identifier can be escaped by doubling them; this is not possible with the closing square bracket:
CREATE TABLE """"(...) -- table name is one double quote
In UITextView I write my text and on the button click this text store in database but when I use apostrophe(') sign in my text. My query shows me error near apostrophe sign then please tell me how to insert apostrophe sign in sqlit database.
thanx in advance...
You could try to double the apostrophe sign in your text (i.e. '' instead of ').
This may be of some help as well when you want to replace a single quote with two double quotes.
Method:
- (NSString *)stringByReplacingOccurrencesOfString:(NSString *)target withString:(NSString *)replacement
Example:
[someString stringByReplacingOccurrencesOfString:#"'" withString:#"''"]
You should double the apostrophe ' to be double ''
A string constant is formed by enclosing the string in single quotes
('). A single quote within the string can be encoded by putting two
single quotes in a row - as in Pascal. C-style escapes using the
backslash character are not supported because they are not standard
SQL.
http://www.sqlite.org/lang_expr.html
In my application I am trying to read some data from sqlite database into UITextView.
This text has double quotes as well as single quotes, for ex:
she said : "Katie's purse has been
lost"
when I do this, I get strange characters in place of double and single quotes. Please help me with a solution to scrub these characters off.
Thanks.
If you get one strange character (or set of characters) replacing " and another replacing ', you can just scan the string and replace. If you aren't, then:
That's very strange, and
You should post your code.