I'm interested in the question, Is it possible to replace MySQL database with JSON files for WordPress? Let me explain what I mean. We have 12 standard tables after WordPress installation. We can write each of them into separate JSON file so that each file will be named as its respective table e.g. wp_posts.json, wp_options.json etc. And each file will contain table rows like



or some other format

So the main question is, How to listen or intercept every SQL-query made by WordPress and give back the right result from the right JSON file? And write data into JSON file if the SQL-query is UPDATE or INSERT

For example if SQL-query from WordPress is like

SELECT siteurl FROM wp_options WHERE id = 1

we read the wp_options.json, find the row no. 1 and give back the option_value

As I can understand, all queries are being handled in the wp-includes/wp-db.php file but I don't know what should I start from. Could you at least describe the general steps or maybe there is a tutorial in details or plugin for the purpose?

Or maybe we can listen MySQL host and port?

  • That sounds about right, although it might be simpler to port it to use an embedded database like sqlite or H2 instead of JSON. But if you can't host with MySQL then it might be easier to run your WordPress offline and then use one of the cache plugins to generate a static version of your site to upload to host. Or use something else, e.g. Jekyll. Or do you need an interactive site without MySQL? – Rup Mar 12 '19 at 11:37
  • I would like to use WordPress on local computer but only with binary PHP CLI for Windows and without MySQL and Apache – stckvrw Mar 12 '19 at 11:40
  • It's going to be simplest to just run MySQL I think. If you want to keep it isolated then you could e.g. run it inside Docker if you have that installed? If you just need this for development you can install MySQL as a service but make it manual start so that it isn't always running when you're not using it. But an embedded database like SQLite would also work well for this case, though I don't think it's supported anymore. – Rup Mar 12 '19 at 11:54
  • 1
    On second glance it looks like there is a current SQLite plugin: wordpress.org/plugins/sqlite-integration – Rup Mar 12 '19 at 12:40
  • Thanks. See also https://wordpress.stackexchange.com/a/6422/144565 – stckvrw Mar 19 '19 at 10:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.