1

I'm running a python script on a read only system. Because I'm dealing with a lot of files I want to have some kind of database. But since it's read only I just need that in ram. I could safe all the information in variables, but I'd love to be able to query in a more complex way. So is there a trick to get something like a mysql database, but not saving in to the memory card?

I know I could create a tmpfs, but maybe there is a more clever way!?

I'm running Raspbian (like Debian) on my raspberry pi.

1 Answer 1

1

You want sqlite! Use it pretty much just like you would use MySQL, except that you can run it entirely in memory with no setup or configuration hassles.

When you create a "connection" object to a MySQL database you are actually reaching out over the network and connecting to a remote resource, but when you create a "connection" object in sqlite, that creates the (single-user-at-a-time) database on the fly and does not access external resources.

Sign up to request clarification or add additional context in comments.

4 Comments

Are the queries the same? At the first glance it looks like it.
@JasonTS: It is SQL, yes. There are no doubt some MySQL-specific things that won't work, but basic SQL stuff is the same.
Thanks a lot. Just one more question: Do I need to worry about a connection timeout when just using the db in memory?
@JasonTS No, you do not. The "connection" is virtual; there is not actually any server to time out a connection, there is only the memory block and a protocol for accessing it inside the host process via SQL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.