How to check SQLite3 syntax?

Is there a way to check the syntax of a SQLite3 script without running it?

Basically, I'm looking for the equivalent of the SQLite3 ruby -c script.rb, perl -c script.pl, php --syntax-check script.phpetc.

I was thinking about using explain, but most of the scripts that I would like to test are stored for reference purposes (and do not necessarily have a related database). Using explainalso makes it difficult to use with something like Syntastic . (That is, I only want to check the syntax, not the semantics.)

Update:

I'm confused. Let's say I want the syntax to check this:

select * from foo;

I could do something like:

echo 'explain select * from foo;' | sqlite3

But then I get:

SQL error near line 1: no such table: foo

All I expect to see is OK Syntax (or something similar). Is it possible?

+3
3

, , - Ruby sqlint

ANSI SQL: sqlite.

2015 , 5 ,

Ruby C ( pg_query.)

: $ sqlint ex7a.sql ex7a.sql:81:10:ERROR syntax error at or near "*"

Unix, , sqlint . , .

+1

, EXPLAIN . sqlite3 , ": memory:" sqlite3_open_v2().

0

, EXPLAIN. , , EXPLAIN.

0
source

Source: https://habr.com/ru/post/1747423/


All Articles