Import and export with MYSQL commands ?

closed

I love your product and thanks for all the efforts and generosity having this as a free version . I wonder where the question data is stored and if mysql commands can be done to write bulk exports and imports . Is it possible ?

August 5, 2023 at 3:23amTore W Jakobsen

Hi Tore,
this is a complicated question to answer. Short answer, is yes – it’s possible, but is almost certainly not worth the work required to do this with just plain SQL. Instead, please read the following.

If you only want to import new questions, use the CSV import tool built into HD Quiz. This can be found under HD Quiz ⇾ tools. This would be by FAR the easiest way to import new questions/quizzes as the importer takes care of ensuring that the data is entered and stored in a compatible and safe way.

If you want to export questions from one site and import into another, you can use WordPress’ native import/export tools (Which HD Quiz is fully compatible with!). This tool can be found by logging into your site and selecting Tools ⇾ Export ⇾ and then making sure only “Questions” are selected. WordPress will then create an XML export file that you can use to then import into a new site.

If you want to do more, then I can recommend looking at ./hd-quiz/includes/tools/csv_import.php. This file contains the main functionality that takes a CSV file and then runs functions to transmute the data to be saved in WordPress in a way that HD Quiz can read. The real good stuff happens starting line 200.

The way HD Quiz works is by utilizing two WordPress features. Custom taxonomies, and custom post types. Quizzes are custom taxonomies, and questions are a custom post type. So if you were to power through with a pure SQL solution, you need to look at your queries through the lens of how WordPress saves data for taxonomies and custom post types, as well as replicate the way that I am storing post meta for questions and quizzes in HD Quiz.

At the end of the day, if you need to run custom queries to either get or save custom data, you are better off doing so within WordPress instead of within SQL (which one again, take a look at csv_import.php to see a more “raw” version of this).

Hope this at least helps point you in the right direction!

05 August 2023 — 17:44support admin Dylan

This thread has either been marked as complete or has been automatically closed due to inactivity. Please consider opening a new support thread for help.