question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SURVEY: SQL-Like or Shell command syntax

See original GitHub issue

Hello everyone!

I’m writing a new version of LiteDB with better support to string command parser. This language can be used in external tools or via Run method. Also, in new v5 server-mode, this language will be used in REST API and any other protocol to transfer command. SQL syntax are simple and easy do adopt because everyone know SQL. Read reference are almost not needed.

Some examples:

Using SQL-Like syntax

-- Simple data select
SELECT *
  FROM customers
 WHERE name = 'John'

-- Add data transformation
SELECT *,
       phones[type = 'mobile'].number AS mobile
  FROM customers

-- Full query syntax  
 SELECT *
   INTO new_col
   FROM customers
  WHERE _id BETWEEN 0 AND 100
    AND name = "John"
INCLUDE orders, address
  ORDER BY YEAR(birthday)
  LIMIT 100
 OFFSET 10

-- Select with group by 
SELECT key AS age
       COUNT(values) AS counter
  FROM customers
 GROUP BY YEAR(birthday)

-- Creating an index
CREATE UNIQUE INDEX idx_0 ON customers (LOWER(email))

-- Insert data
INSERT INTO customers 
     VALUES { name: "John", year: 2018 } 
         ID INT

-- Update         
UPDATE custumers
   SET name = UPPER(name)
  WHERE year < 2018

And here, same Shell syntax

-- Simple data select
db.customers.select $
              where name = 'John'

-- Add data transformation
db.customers.select EXTEND($, { mobile: phones[type = 'mobile'].number })

-- Full query syntax  
db.customers.select $
               into new_col
              where _id between [0, 100]
                and name = "John"
            include orders, address
              order by YEAR(birthday)
              limit 100
             offset 10

-- Select with group by 
db.customers.select { age: key, counter: COUNT(values) }
              group by YEAR(birthday)

-- Creating an index
db.customers.createIndex idx_0 { expr: LOWER(email), unique: true }

-- Insert data
db.customers.insert { name: "John", year: 2018 } id:int

-- Update         
db.custumers.update EXTEND($, { name: UPPER(name) })
              where year < 2018

Can vote with: ❤️ for SQL 👍 for Shell

Any comment are welcome!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:15
  • Comments:15 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
mbdavidcommented, Oct 2, 2018

Hi @janantos, my first idea was keep all together but I change my mind when next version grows a lot. So, I will keep this feature as a external plugin… and will be deliver only after final v5 version

1reaction
janantoscommented, Oct 2, 2018

HI, I would like to keep LiteDB simple. server mode can be implemented on top of it as separate project, myself thinking about creating oData interface for LiteDB

Read more comments on GitHub >

github_iconTop Results From Across the Web

Databases and SQL: Selecting Data
BASH. $ cd /path/to/survey/data/ $ sqlite3 survey.db. The SQLite command is sqlite3 and you are telling SQLite to open up the survey.db ....
Read more >
SQL LIKE Operator
CustomerID CustomerName ContactName Address 1 Alfreds Futterkiste Maria Anders Obere Str. 57 2 Ana Trujillo Emparedados y helados Ana Trujillo Avda. de la Constitución... 3 Antonio...
Read more >
SQL LIKE Statement – How to Query SQL with Wildcard
For example, this is the syntax to find all numbers in the quantity category that are 2 digits long and end with '9':...
Read more >
Basic SQL Commands - The List of Database Queries and ...
Here is a list of basic SQL commands (sometimes called clauses) you should know if you are going to work with SQL. SELECT...
Read more >
Use of like "%" character in sql query changes my ...
I am new to shell scripting and trying to read a list of employee IDs from a text file as part of my...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found