Skip to content

Query tools: corasql and drivers

View as Markdown

corasql is the command-line SQL interpreter installed with CoraDB. It runs SQL and graph queries interactively or from files, and offers session commands for schemas, plans, traces and parameters. The corasql interpreter page describes all its options and commands.

Start it with a user and a database name. The users DBA and PUBLIC exist in every database and have no password until one is set:

corasql -u dba e-commerce

Type a statement ending with a semicolon to run it, and ;help to list the session commands:

SELECT c.company_name, COUNT(*) AS orders
FROM orders o JOIN customer c ON c.id = o.customer_id
GROUP BY c.company_name ORDER BY 2 DESC, 1 LIMIT 3;
company_name orders
Kelly Ltd 49
Mayer, Carroll and Owens 40
Young and Sons 40

Statements can also be run without the interactive prompt, from the command line (-c) or from a file (-i), with output formats for scripts (-t, -q, -d):

corasql -u dba -c "SELECT COUNT(*) FROM orders" e-commerce
corasql -u dba -i monthly_report.sql -o monthly_report.txt e-commerce

Leave corasql with ;exit.

Applications connect through the CoraDB broker with one of the drivers:

Language Driver
Java JDBC
JavaScript / TypeScript Node.js
PHP PHP
C# / .NET ADO.NET
Python Python
C / C++ CCI