nalgeon / sqlime

Online SQLite playground

Home Page:http://sqlime.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support embedding into another application

buckett opened this issue · comments

I'm thinking about looking at embedding SQLime into another application so that people teaching SQL can embed SQLime into teaching materials where the embedded display preloads some SQL, but then allows the students to practice querying it. This integration would take care of storing the preloaded materials and things like remembering the SQL entered by the students.

If this can be made generic would these sorts of changes be useful to be included back in a PR or do you have any thoughts about this more generally?

I've been thinking about the same thing lately :) As I see it, there is no need for a full-fledged SQLime UI in this use case (with sharing, import, settings etc). What we probably need is a widget capable of running SQL queries and showing the results.

Something like this:

┌───────────────────────────────────────────┐ 
│ select * from employees                   │
│ order by salary;                          │
│                                           │
│ run ►                                     │
└───────────────────────────────────────────┘
 ✓ 10 rows, took 2 ms
┌────┬───────┬────────┬────────────┬────────┐
│ id │ name  │  city  │ department │ salary │
├────┼───────┼────────┼────────────┼────────┤
│ 11 │ Diane │ London │ hr         │ 70     │
│ 12 │ Bob   │ London │ hr         │ 78     │
│ 21 │ Emma  │ London │ it         │ 84     │
│ 22 │ Grace │ Berlin │ it         │ 90     │
│ 31 │ Cindy │ Berlin │ sales      │ 96     │
│ 32 │ Dave  │ London │ sales      │ 96     │
│ 33 │ Alice │ Berlin │ sales      │ 100    │
│ 23 │ Henry │ London │ it         │ 104    │
│ 24 │ Irene │ Berlin │ it         │ 104    │
│ 25 │ Frank │ Berlin │ it         │ 120    │
└────┴───────┴────────┴────────────┴────────┘

Would this be enough in your opinion?

@nalgeon Yep, that looks pretty good place to start.

Maybe keep the ○ tables as that allows discovery when the example is more complex.

Okay, here we go! See the Executable SQL Examples in JavaScript. I've decided to start with a lightweight widget and add the full playground widget later.

I'm pretty happy with the results for now. But if you have a real-world use case that requires a full-blown Sqlime playground as a widget — let me know.