How to access SQLite from Raspi on a Raspi or from Windows on a Raspi - Read Only

  1. 10 months ago

    Tim S

    26 Dec 2018 Pre-Release Testers, Xojo Pro Phoenix Arizona USA

    Hello all.

    I need to access a SQLite database running on a Raspberry pi from either or another Raspi or a windows machine. This is a read only connection, so no worry about latency or file locking (I think).

    Thanks in advance!
    Tim

  2. Ivan T

    26 Dec 2018 Pre-Release Testers
    Edited 10 months ago

    SQLite is NOT for shared enviroments.

    - If it is read only, just copy the same file to all the devices.

    - Create a simple service in the device with the database and send the responses in JSON

    - Use a real dbms

  3. Tim S

    27 Dec 2018 Pre-Release Testers, Xojo Pro Phoenix Arizona USA

    Hello Pedro.

    Cannot copy to all, unless it was to be done frequently which makes little sense. Just want to read certain tables.

    How to connect from RPI to RPI over network? Just use an IP + path or what?

    BTW, even with PostgreSQL, which is my alternative, I'd still have the same question - is connecting different?

    Thanks,
    Tim

  4. Jay M

    27 Dec 2018 Pre-Release Testers, Xojo Pro NC, USA

    I don't think PostgreSQL server works on a Raspberry pi, which is what you'll need to have a PostgreSQL database.

    SQLite must have direct access to the database file, so you'll need a file sharing connection to the pi that has the database.

  5. Bob K

    27 Dec 2018 Pre-Release Testers, Xojo Pro, Third Party Store Kansas City

    Connecting to a database server from different machines is easy. There is no easy to do what you're asking for since it's a SQLite database.

    However, using a TCP socket on the Pi you can have any computer on your network connect to it via a TCPSocket and query for what data is desired. The drawback is that you do all the work of packaging the query and result messages. Take a look at EasyTCPSocket as it will simplify the process.

  6. Tim S

    27 Dec 2018 Pre-Release Testers, Xojo Pro Phoenix Arizona USA

    Thanks again for the responses everyone.
    Postgre can run on the pi - here's a nice little how to
    https://opensource.com/article/17/10/set-postgres-database-your-raspberry-pi

    Bob, how do you connect to a POSTgreSQL server from a different machine? Sounds like that is what I will need to do....
    Thanks again all!
    Tim

  7. Bob K

    27 Dec 2018 Pre-Release Testers, Xojo Pro, Third Party Store Kansas City

    @Tim S Bob, how do you connect to a POSTgreSQL server from a different machine? Sounds like that is what I will need to do....

    Just like you connect to ANY Postgres DB. I don't understand the question since Postgres is a DB server it's designed to be connected to by other computers. At that point you don't need Postgres on the Pi, just on a computer on the network. AFAIK Pi apps can connect to Postgres (never tried myself).

  8. Tim S

    27 Dec 2018 Pre-Release Testers, Xojo Pro Phoenix Arizona USA

    Hi Bob,

    The Pi is the master, doing all of the work. The other is to display certain info. When using Postgre, or Pervasive, I've only ever connected on the same computer, never over a network, internet etc.....

    Tim

  9. Jay M

    27 Dec 2018 Pre-Release Testers, Xojo Pro NC, USA
    Edited 10 months ago

    @Tim S Postgre can run on the pi - here's a nice little how to
    https://opensource.com/article/17/10/set-postgres-database-your-raspberry-pi

    Wow, didn't know that!

    To connect to PostgreSQL on another machine, supply the hostname, which can be a network name or simply a IP address, and of course port, username and password.

  10. Tim S

    27 Dec 2018 Pre-Release Testers, Xojo Pro Phoenix Arizona USA

    Have to open the port permissions so it is accessible from outside right?
    Thanks again!
    Tim

  11. Jay M

    27 Dec 2018 Pre-Release Testers, Xojo Pro NC, USA

    @Tim S Have to open the port permissions so it is accessible from outside right?

    Yes

  12. Bob K

    27 Dec 2018 Pre-Release Testers, Xojo Pro, Third Party Store Kansas City

    Still seems like overkill. If the Pi is connected to a network there's no reason why it can't just connect to a db server.

  13. Tim S

    28 Dec 2018 Pre-Release Testers, Xojo Pro Phoenix Arizona USA

    Hi Bob,
    The issue is, all of the data is collected and maintained on the pi. So if a server is required, it must be on the pi.

    I thought I could just connect to the SQlite db to do a read, and maybe I can; especially since there is no time sensitivity with the reading. The other PI or PC will be displaying a graphical representation which can be many seconds off from reality....

    Thanks again!

    Tim

  14. Tim S

    29 Dec 2018 Canterbury, UK

    @Tim S I thought I could just connect to the SQlite db to do a read, and maybe I can; especially since there is no time sensitivity with the reading. The other PI or PC will be displaying a graphical representation which can be many seconds off from reality....

    Well if all you're doing is reading then you probably could connect to it to do a read, although this sort of thing is not recommended (particularly if you were writing to the remote SQLite db). The problem: networked file systems tend to lie about whether they've actually written data to disk. You're reading in this case so it probably won't matter.

    Make sure you set a timeout for your connection to avoid getting SQLITE_BUSY on your actions.

  15. Tim S

    29 Dec 2018 Pre-Release Testers, Xojo Pro Phoenix Arizona USA

    So to connect, do I use an IP + an internal path to the SQLite database?

    Thanks,
    Tim

  16. Ivan T

    29 Dec 2018 Pre-Release Testers

    @Tim S So to connect, do I use an IP + an internal path to the SQLite database?

    Thanks,
    Tim

    lol

    It is better if you make a web service to share the fata with a json. The server can connect to the local database

  17. Tim H

    29 Dec 2018 Pre-Release Testers Portland, OR USA

    Tim, You cannot access an SQLite database via IP. That's for database services such as Postgres. SQLite is strictly a file based system designed to be used on the local drive. AFAIK, you cannot open an SQLite database read-only from Xojo. And you shouldn't attempt to access it via a mapped drive. SQLite cannot handle multiuser file locking. The "MultiUser" property is misleading. It allows concurrent access from multiple processes on the same machine. Not true multiuser access.

  18. Tim S

    30 Dec 2018 Pre-Release Testers, Xojo Pro Phoenix Arizona USA

    Hi Tim.
    Happy new year to you!
    So it's just a simple path, will try it out and see how it goes.

    Tim

  19. Tim S

    30 Dec 2018 Canterbury, UK

    @Tim S Hi Tim.
    Happy new year to you!
    So it's just a simple path, will try it out and see how it goes.

    To which Tim are you responding?
    You should probably look here before investing too much time.

  20. Tim S

    30 Dec 2018 Pre-Release Testers, Xojo Pro Phoenix Arizona USA

    All Tims!... Tim Streater!

    Tim

  21. Newer ›

or Sign Up to reply!