Skip to content

Commit

Permalink
sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
vickeykumar committed Jun 17, 2024
1 parent 96935ed commit 72ec391
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 2 deletions.
4 changes: 4 additions & 0 deletions install_prerequisite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ cd ~
#install tcl
apt-get install -y --no-install-recommends tcl

#install sqlite3
apt-get install -y --no-install-recommends sqlite3

# Docker: Error response from daemon: cgroups: cgroup mountpoint does not exist: unknown
# if using docker use privileged mode with cgroup mounted (-v /sys/fs/cgroup:/sys/fs/cgroup:rw )
mkdir /sys/fs/cgroup/systemd || true
Expand Down Expand Up @@ -225,6 +228,7 @@ if [ $run_tests -eq 1 ]; then
"rustc --version"
"rust-gdb --version"
"evcxr --version"
"sqlite3 --version"
)


Expand Down
1 change: 1 addition & 0 deletions src/containers/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var Commands2memLimitMap = map[string]int64{
"tclsh": 2,
"java": 128, // jvm takes lot of memory
"evcxr": 50, // rust REPL
"sqlite3": 10,
}

var memLimitMutex sync.Mutex
Expand Down
6 changes: 6 additions & 0 deletions src/resources/chat-widget/src/openreplkeywords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ export const documentation = `\nOpenREPL is an Online platform for checking code
"title": "Rust Book",
"documentation": "https://doc.rust-lang.org/book/title-page.html",
"github": "https://github.com/evcxr/evcxr"
},
{
"language": "SQLite",
"title": "SQLite Doc",
"documentation": "https://sqlite.org/cli.html",
"github": "https://github.com/sqlite/sqlite"
}
]
}`
3 changes: 2 additions & 1 deletion src/resources/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ <h1 class="hero__title" itemprop="name" ><span class="hero__title_pre">Open</spa
<option value="bash" data-editor="sh">bash</option>
<option value="tclsh" data-editor="tcl">Tcl</option>
<option value="evcxr" data-editor="rust">Rust</option>
<option value="sqlite3" data-editor="sql">SQLite</option>
</select>

<div class="widget" id="fork-widget" style="margin:7px;font-size:15px;height:25px;">
Expand Down Expand Up @@ -462,7 +463,7 @@ <h2>Welcome to <span class="go__color">Open</span>REPL</h2>
<option value="snippets" disabled>snippets</option>
<option value="soy_template" disabled>Soy Template</option>
<option value="space" disabled>Space</option>
<option value="sql" disabled>SQL</option>
<option value="sql">SQLite</option>
<option value="sqlserver" disabled>SQLServer</option>
<option value="stylus" disabled>Stylus</option>
<option value="svg" disabled>SVG</option>
Expand Down
3 changes: 2 additions & 1 deletion src/resources/js/scribbler.js
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,8 @@ $(function() {
'yaml': 'yaml',
'proto': 'protobuf',
'tcl': 'tcl',
'rs': 'rust'
'rs': 'rust',
'sql': 'sql'
};
const imageext = ['jpg', 'jpeg', 'gif', 'png', 'bmp', 'webp', 'svg', 'ico'];
const archiveext = ['zip', 'rar', '7z', 'tar', 'gz', 'bz2'];
Expand Down
125 changes: 125 additions & 0 deletions src/resources/meta/demos.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2032,6 +2032,131 @@ if [ $? -eq 0 ] &amp;&amp; [ -f "$WORKDIR/$FILE" ]; then
fi
fi
printf "\n";
sleep 0.05
</Compiler>
</Demo>

<!-- SQL demo -->
<Demo>
<Name>sqlite3</Name>
<Github>https://github.com/sqlite/sqlite</Github>
<Doc>https://sqlite.org/cli.html</Doc>
<Codes>
<Code>
<Prompt>sqlite&gt;</Prompt>
<Statement>create table tbl1(one text, two int);</Statement>
</Code>
<Code>
<Prompt>sqlite&gt;</Prompt>
<Statement>insert into tbl1 values('hello!',10);</Statement>
</Code>
<Code>
<Prompt>sqlite&gt;</Prompt>
<Statement>insert into tbl1 values('goodbye', 20);</Statement>
</Code>
<Code>
<Prompt>sqlite&gt;</Prompt>
<Statement>select * from tbl1;</Statement>
<Result>hello!|10
goodbye|20</Result>
</Code>
</Codes>
<Codes>
<Code>
<Prompt>sqlite&gt;</Prompt>
<Statement>.open ex1.db</Statement>
</Code>
<Code>
<Prompt>sqlite&gt;</Prompt>
<Statement>.save ex1.db</Statement>
</Code>
</Codes>
<Codes>
<Code>
<Prompt>sqlite&gt;</Prompt>
<Statement>.help</Statement>
<Result>.archive ... Manage SQL archives
.auth ON|OFF Show authorizer callbacks
.backup ?DB? FILE Backup DB (default "main") to FILE
.bail on|off Stop after hitting an error. Default OFF
.cd DIRECTORY Change the working directory to DIRECTORY
...
.dump ?OBJECTS? Render database content as SQL
.echo on|off Turn command echo on or off
.eqp on|off|full|... Enable or disable automatic EXPLAIN QUERY PLAN
.excel Display the output of next command in spreadsheet
...
</Result>
</Code>
</Codes>
<Usage>
<Command>.help</Command>
<Description>Print command help</Description>
</Usage>
<Usage>
<Command>.quit</Command>
<Description>Quit evaluation and exit</Description>
</Usage>
<Content>-- Welcome to OpenREPL!
-- Create the Resources table
CREATE TABLE IF NOT EXISTS Resources (
id INTEGER PRIMARY KEY AUTOINCREMENT,
language TEXT,
title TEXT,
documentation TEXT,
github TEXT
);

-- Insert the data
INSERT INTO Resources (language, title, documentation, github) VALUES
('C++', 'Cling Documentation', './docs/cling.html', 'https://github.com/root-project/cling'),
('Go', 'Yaegi Documentation', 'https://pkg.go.dev/github.com/traefik/yaegi', 'https://github.com/traefik/yaegi'),
('Go', 'Go Interpreter Documentation', './docs/gointerpreter.html', 'https://github.com/vickeykumar/Go-interpreter'),
('jq', 'jq Manual', 'https://stedolan.github.io/jq/manual', 'https://github.com/vickeykumar/jq-repl'),
('Python', 'Python Documentation', './docs/python.html', ''),
('Java', 'Java Documentation', './docs/java.html', 'https://github.com/javaterminal/tryjshell'),
('Bash', 'Linux Command', 'http://linuxcommand.org/index.php', ''),
('Ruby', 'Ruby Quickstart', 'https://www.ruby-lang.org/en/documentation/quickstart/', ''),
('JavaScript', 'JavaScript Documentation', 'https://developer.mozilla.org/bm/docs/Web/JavaScript', 'https://github.com/vickeykumar/jsconsole'),
('Node.js', 'Node.js REPL Documentation', 'https://nodejs.org/dist/latest-v10.x/docs/api/repl.html', 'https://github.com/nodejs/node'),
('Perl', 'Perl Tutorials', 'https://www.guru99.com/perl-tutorials.html', 'https://github.com/mklement0/perli'),
('Tcl', 'Tcl Tutorial', 'https://www.tcl.tk/man/tcl8.5/tutorial/tcltutorial.html', ''),
('Rust', 'Rust Book', 'https://doc.rust-lang.org/book/title-page.html', 'https://github.com/evcxr/evcxr'),
('SQLite', 'SQLite Doc', 'https://sqlite.org/cli.html', 'https://github.com/sqlite/sqlite');

-- List all records
SELECT * FROM Resources;
</Content>
<Compiler>
COMPILER=sqlite3
FILE=test.sql
debug=false
WORKDIR=$HOME
if [ "$CompilerOption" = "debug" ]; then
debug=true;
fi

if [ "$IdeFileName" != "" ]; then
WORKDIR=$(dirname "$IdeFileName");
FILE=$(basename "$IdeFileName");
else
echo $0|base64 --decode > "$WORKDIR/$FILE";
fi

cd $WORKDIR;
if [ $? -eq 0 ] &amp;&amp; [ -f "$WORKDIR/$FILE" ]; then
if $debug; then
$COMPILER $@&lt;&lt;EOF
.eqp full
.echo on
.timer on
.read $FILE
EOF
else
$COMPILER $@ -init $FILE
fi
fi
printf "\n";
sleep 0.05
</Compiler>
</Demo>
Expand Down

0 comments on commit 72ec391

Please sign in to comment.