![]() |
Re: Editing/Appending SQLite files
|
Re: Editing/Appending SQLite files
Man!, where are my posts going?........what the fk is going on!, lol......I posted here 20 minutes ago, now it's gone.
I got a result of sorts. I managed to work out the command to sort my sqlite contents either by ID or station....great!, but that only sorts the output on screen, it doesn't sort the contents physically and so, when viewed in the app on my phone, the list still has a clump of new stations at the bottom - I guess there is something wrong with the file itself. The command, as stated by rinigus, was as follows; SELECT * FROM stations ORDER BY STATION ASC; (I then read that ASC is set by default, so I can omit that in future). (let's see if this post stays put!)....... |
Re: Editing/Appending SQLite files
Don't worry, I see plenty of posts! I've had a play with a list of pokemon (first file I found) and got just as far as you in sorting an output, now just need to direct it into a different table...
|
Re: Editing/Appending SQLite files
Markyyboy, how exactly are you trying to retrieve data?
Have you tried the following SQL statement: Quote:
|
Re: Editing/Appending SQLite files
To document this properly I did:
Find current field names Code:
PRAGMA table_info(stations); Code:
CREATE TABLE temp_table (id INTEGER PRIMARY KEY, station TEXT, favourite INTEGER) ; Code:
INSERT INTO temp_table (station, favourite) SELECT station, favourite FROM stations ORDER BY STATION ASC ; Code:
DROP TABLE stations ; Code:
ALTER TABLE temp_table RENAME TO stations ; |
Re: Editing/Appending SQLite files
Quote:
Presumably you have a Sailfish device, head to Jolla Store and download NationalRail app. By doing this, you will have the 'stationsDB.sqlite' file found in '/usr/share/harbour-nationalrail/data' folder The sqlite list is out of date, there are more than 18 new stations to add to the list.....or I am now thinking the file should be made from scratch and incorporate a way to make updating easier in future releases. |
Re: Editing/Appending SQLite files
Can you see my post above yours? The problem is solved :)
|
Re: Editing/Appending SQLite files
wow!, hats off to you suicidal_orange (is that a colour or a depressed fruit?), thank you!......so let me get this straight, you never used sqlite before and yet within a couple of hours, you got it sorted!, bloody genius!.
So, as I append new stations, will I have to do the same maneuvers? thanks, Mark |
Re: Editing/Appending SQLite files
Quote:
Any program that reads the data from the sqlite database is always going to use some select statement. If that select statement has an "order by" clause, then the data will be returned to the app ordered even though it isnt ordered on disk. In other words, do not waste your time resetting the on disk format again and again. Use the correct select from order by statement and let SQL do that heavy lifting. This sort of thing is exactly why you're supposed to use SQL and not a flat text file. |
Re: Editing/Appending SQLite files
Very true uvatbc, this should be fixed in the program doing the query but at least new train stations aren't an everyday occurrence.
That said it's a bit strange the original programmer didn't use a flat file so the list was easy to edit being as there are only two fields in a single table. Then again if they were future proofing they would have sorted in the query in the first place... Quote:
Quote:
As above the program is designed badly so yes, you'll need to do this whenever you add a station. Unless it starts with Z! |
All times are GMT. The time now is 23:08. |
vBulletin® Version 3.8.8