Skip to content
This repository was archived by the owner on Aug 4, 2020. It is now read-only.

Conversation

@shriakhilc
Copy link

Refers #17

Station name to code mapping added as per an official Indian Railways document here. It contains 711 stations total.

While other sources list up to 8000 stations, those also seem to include goods stations where passenger trains don't usually stop. Nonetheless, I will still be scraping them and updating the file in the future.

@prinzpiuz
Copy link
Owner

sorry for the comment . i didnt noticed it actually will test and tell you

@prinzpiuz
Copy link
Owner

but making such large dict/json will effect perfomance issue...?

@shriakhilc
Copy link
Author

There are 3 common persistence solutions in Python that can be used - The pickle module, the sqlite3 module and using external files, commonly JSON, YAML, or XML.

I browsed a number of posts and checked the performance statistics over the years. This StackOverflow Answer is the latest one for that question regarding pickle vs json performance. It seems that json used to be faster for str initially, but pickle should be faster now in most cases. Note that the latest Python3 pickle module internally uses the faster cPickle implementation if possible, and cPickle is no longer available as a separate module.

Now, whether to use pickle or sqlite3 depends on what will be done with the data. Pickle simply stores and retrieves the entire dict object as a byte stream, whereas sqlite3 can provide proper query support.

If whatever "fuzzy search" that is planned to be implemented can be done with a simple SQL Query, then sqlite3 would be a better choice. Otherwise, the entire dict can be loaded as an object, and can be used as the source for said search operation (whether from a library, or implemented yourselves).

I can update the PR with a suitable file depending on your choice.

@shriakhilc shriakhilc closed this Oct 31, 2018
@shriakhilc shriakhilc reopened this Oct 31, 2018
@prinzpiuz
Copy link
Owner

i think sqlite3 will be the better choice otherwise if entire dict loaded as object it will effect the perfomance i think .....also can you join this group for more discussions with other members... https://t.me/RailgadiBotDiscussions

Add a SQLite database with a table `station_codes`

Refers #17
@shriakhilc
Copy link
Author

Updated the PR. Switched from the JSON file to using a SQLite database.

The name of the database is railwaybot.db and it has a table called station_codes with two columns name and code both of type TEXT.

Documentation for using Python 3 's sqlite3 module : sqlite3

The added advantage of using a SQLite database is that we will be able to filter the station names based on current user input using wildcard characters and the WHERE and LIKE keywords.

For example if the user is typing "Lucknow" :

select * from station_codes where name like "luck%"

This will be useful when there are many stations within the same city, as with a lot of larger ones.

@shriakhilc
Copy link
Author

@prinzpiuz can this be merged now?

@prinzpiuz
Copy link
Owner

need to be tested and need to make bot inline also then only i think this feature works... everybody in group is busy i think

@prinzpiuz
Copy link
Owner

let me make inline commands

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants