I’d like to use my own database instead of CoderPad’s sample DB. How do I do that?
First, you’ll need to set up a custom database. If you’ve set up a CoderPad custom database before, you’ll follow the same steps. Go to Custom Databases, and follow the instructions to load and initialize a new MySQL or PostgreSQL custom database. Make sure it initializes before moving to the next step. CoderPad automatically generates the SQL schema to be displayed in the pad!
If you have previously set up a custom database that you want to use, you can skip this step and add the DB to a question in the next step.
Next, go to the Question Bank. Click “Write New Question”, then choose one of the supported Full-Stack Database languages (below) from the “Language” dropdown. If you choose an unsupported language, you won’t be able to use a Full-Stack Database at this time. The following adaptors are available for supported languages:
- Java – JDBC adaptor
- Python 2 & 3 – SQLAlchemy
- C++ – MySQL Connector, libpqxx (PostgreSQL)
- Ruby – ActiveRecord, Sequel
- C# – Dapper, Entity Framework, MySQL Connector, Npgsql
Give your question a descriptive title, add a custom file if you want the candidate to also work with a data file, and then select your custom database from the “Custom Database” dropdown menu. This attaches the custom database to this question. Loading a question with a database into a pad is the step that loads the database.
If you want to provide any additional starting code or write instructions for the candidate ahead of time, add that to the “Contents” section, and save the question.
Final step: use the Full-Stack Database in an interview! Once you’ve created or joined the pad for an interview, click on the “Questions” menu, search for your question, and click “Replace Pad”. This will load your question, and you or the candidate can select the language and database adaptor to use and start coding.
Please note: loading the DB adaptor code will comment out all existing code, including any question code. Best practice is to load the question at the start of the interview, and you may need to rearrange code a little once you load the adaptor. This approach does provide the most flexibility in candidate interview language choice or preferred DB adaptor.
Also keep in mind that the adaptor package is just helper code. You also have the option to paste in the adaptor code when setting up a question. This lets you skip the package loading step, as the database will always be loaded with the question, not the package. This does require you to select a particular language and adaptor for the candidate to use when setting up the question, so there is less flexibility at interview time.
- Full-Stack Databases work much like CoderPad’s original MySQL and PostgreSQL environments.
- If you set up your own custom database, the original DB will always be saved and never edited; a copy is loaded for each new interview session.
- Edits – such as row inserts, updates and deletes – are stateful during a specific interview session and persist between subsequent code execution.
- You can reset the DB back to its original unmodified state during a specific interview by pressing the Reset button in the top right corner.
- Original CoderPad MySQL and PostgreSQL environments still work exactly as before. If you want to test a candidate on only SQL, you can keep using your existing MySQL and PostgreSQL questions in those environments.