SQLite mysterious spaces

I have a app that interfaces with sqlite.
First, I have it entering information into the db so I can retrieve it later.

Now, I can go into terminal and pull up the data using “sqlite3 … … … …” and it shows the info exactly as I entered it.

When I tell it to, it queries the db, and populates a text field…but if what I added did not have at least 10 characters, it adds spaces so that it equals 10 characters.
Once again, the database reflects the entry with no spaces, as it should. But once I populate the field, that’s where the spaces appear.

What the heck is going on?

Well, I still can’t get around the spaces but I have come up with a somewhat tedious solution.

First, I query the database:

set qfirstName to "SELECT first FROM entries  WHERE ROWID='" & id_num & "';"

Then, I strip the spaces (found this on another topic) and create a new variable to hold the new data:

set firstName to (do shell script head & qfirstName & quote)
set {old_delim, text item delimiters} to {text item delimiters, space}
set {firstName, text item delimiters} to {words of firstName as string, old_delim}

Then, print the new results to the text field:

set content of text field "firstName" of window 1 to firstName

SQLite will display the output of a select in the “mode” that you tell it to. Your description of 10 character wide output indicates that you’re requesting it in “column” mode.

You don’t actually provide the code that you’re using to get the result of the select, other than a brief reference:

set qfirstName to "SELECT first FROM entries WHERE ROWID='" & id_num & "';"

set firstName to (do shell script head & qfirstName & quote)

but you don’t tell us what the “head” variable is set to. I suspect it contains something that does the equivalent of “-column” which will give you the 10 character wide columns that you describe. If you get rid of that or change it to “-list” then you’ll get non spaced output.


I did have “head” set to “sqlite3 -column”.
I swear I had tried changing that, but upon changing -column to -list again, it seems to work fine.
You were absolutely correct!

Thanks for giving me a second look.