Search code examples
sqlitemojolicious

storing and retrieving GPS value in SQLIte3


I want to store the GPS values like latitude, longitude, and timestamp value in SQLITE3. my schema is like REAL for latitude and longitude and DATETIME for timestamp value.

It was inserted successfully. but when i try to retrieve it show the server error as,

Can't locate DateTime/Format/SQLite.pm in @INC

how to store the timestamp value in SQLite3 database which is the best datatype to store these values. i want to do some computations with that timestamp like time delay etc..

Any useful help will be appreciated. Thanks in advance.


Solution

  • You can store the timestamp in Unix Time such as :

    SELECT strftime('%s', 'now');
    

    Will return something like this : 1367641852

    The result will represent the number of seconds passed since January 1, 1970.

    So you can easily subtract two different timestamps and get the number of seconds as delay between two different times.

    Also you should change your schema for timestamp to INTEGER.