Writing SQL in Coderpad
NickName:user3439308 Ask DateTime:2018-01-14T00:47:21

Writing SQL in Coderpad

I have an interview coming up in which I will write code in Coderpad. What is the syntax to write SQL in Coderpad? (note Coderpad with an "r", not Codepad).

First, you select a language for Coderpad. I am selecting Scala.

Here is a database they provide:

+--------------------+-----------+---------------+
| Table Name         | Row Count | Table Size KB |
+--------------------+-----------+---------------+
| departments        |         5 |       16.0000 |
| employees          |         6 |       32.0000 |
| employees_projects |         5 |       48.0000 |
| projects           |         3 |       16.0000 |
+--------------------+-----------+---------------+

Here is Scala code that does work:

object Solution extends App {
  for (i <- 0 until 5) println("Hello, World!")
}

I want to run a simple SQL query.

SELECT * FROM employees;

Note: I can write complex SQL in Spark with Scala. I have written hundreds of Databricks Scala notebooks. So, I do not need a primer on Scala or SQL.

I simply need the correct SYNTAX to write any simple SQL query in CoderPad just to get me started. Thank you.

In other words, how do I insert a SQL statement into a Scala Object?

I tried:

object Solution extends App {
  //for (i <- 0 until 5) println("Hello, World!")
  val myTest = SQL("select * from employees").as(mapping *)
  myTest.take(1)


}

But get this error:

Solution.scala:6: error: not found: value SQL
  val myTest = SQL("select * from employees").as(mapping *)
               ^
Solution.scala:6: error: not found: value mapping
  val myTest = SQL("select * from employees").as(mapping *)

Copyright Notice:Content Author:「user3439308」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/48242035/writing-sql-in-coderpad

Answers
Vincent Woo 2018-01-13T22:35:38

I'm the guy that makes CoderPad. Currently, you can't connect to MySQL databases in other language environments. That's something we want to do eventually, though.",


More about “Writing SQL in Coderpad” related questions

Writing SQL in Coderpad

I have an interview coming up in which I will write code in Coderpad. What is the syntax to write SQL in Coderpad? (note Coderpad with an "r", not Codepad). First, you select a language for Coder...

Show Detail

What is the name of the theme used by coderpad

I can't seem to find a defined theme used by Coderpad by default see here https://coderpad.io/sandbox The closest thing I found was https://vscodethemes.com/e/SarahRidge.vscode-monokai-minimal how...

Show Detail

How to use coderpad and swift?

I am preparing for a technical interview coming up soon and the online IDE is coderpad. I have been trying to run my code for sometime now and it is simply not printing anything. I know the solutio...

Show Detail

Is it possible to use the ES6 keyword `import` in CoderPad?

Background I'm trying to import the underscore library within coderpad.io (aka CoderPad) This ES5 syntax works: const _ = require('underscore') This ES6 syntax doesn't: import * as _ from &#

Show Detail

What happens when Coderpad creates an interview session?

I am trying to understand on a high level how a system like coderpad works. Everytime I use Coderpad to practice interviews with friends, it creates a session with a temporary link that both users ...

Show Detail

Is it possible to set breakpoints in CoderPad for C#?

Taking an interview within CoderPad for c# and wondering if we can set breakpoints for easy debugging. I looked at the Sandbox they provide and I don't see any obvious way to do it. Are we only lef...

Show Detail

coderpad.io disable blinking cursor

I am looking to disable the blinking cursor in coderpad.io I think its a codeMirror editor. I am using CSS .CodeMirror-cursor, div.CodeMirror-cursor { opacity: 1; display: none; } But t...

Show Detail

How to import npm javascript Priority Queue library when interviewing with coderpad

so Leetcode already supports @datastructures-js/priority-queue which is why I could just use let heap = new MinPriorityQueue() out of the box. But then I realized when I interview with coderpad or

Show Detail

Using CoderPad, why do I get a NoSuchElementException using a Scanner on System.in?

I am preparing for an interview I have in a few days. I was told that I should familiarize myself with CoderPad since that is the collaborator I will be interviewed with. However, I was in the midd...

Show Detail

Why does my code work on Playgrounds but not CoderPad?

I have a very simple func in Xcode playgrounds which works when I run it. But when i try to run the same code in CoderPad it gives me the following error Solution.swift:18:1: warning: result of cal...

Show Detail