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!
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?
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.
Thanks again for the responses everyone.
Postgre can run on the pi - here's a nice little how to
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 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).
@Tim S Postgre can run on the pi - here's a nice little how to
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.
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....
@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.
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.