B4J Question Csv to SQLite program (klaus)

Peter Meares

Member
Licensed User
Longtime User
CSV to SQLite tool
I was using this nice little tool as education and got into trouble with it crashing at the SQL query.

After some debugging I found I had changed the csv file name to include "-" minus sign, which gets carried over in the database name.
I don't know much SQL but the minus sign obvioulsy causes problems.
Error was:
java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (near "-": syntax error)

I guess the (near "-": syntax error) is an obvious pointer to the problem, but I was looking inside the csv file, not in the title becomimg a table name.

I changed this line in the code to add the replace
DBFileName = txfDataBaseFileName.Text.replace("-", "_"):

I suspect there must be other characters that have the same issue but I will stick with underscore now.

Thanks for a nice clear B4J demonstration program.
 

klaus

Expert
Licensed User
Longtime User
Thank you for reporting this.
I had never used minus characters in any filename so i missed this one. I had similar trouble with empty characters.
These were removed from the table name before the conversion.

The updated version 1.4 removes directly empty characters from the table name and replaces "-" by "_".
 
Upvote 0

Peter Meares

Member
Licensed User
Longtime User
Thank you for reporting this.
I had never used minus characters in any filename so i missed this one. I had similar trouble with empty characters.
These were removed from the table name before the conversion.

The updated version 1.4 removes directly empty characters from the table name and replaces "-" by "_".
Klaus
You copied the if statement and I think the " " should have been "-".
Also two entries showing "constained" should be "contained". My nit-picking, sorry.

[CODE lang="b4x" title="If DBTableName.Contains(" ") Then DBTableName = DBTableName.Replace("-", "_") xui.MsgboxAsync("The table name constained '-' character(s), they have been replaced by '_'", "W A R N I N G") End If"][/CODE]

Works well.
 
Upvote 0
Top