General usage information, available features, available magic commands
If you installed the kernel, installed its kernelspec and you have MariaDB installed on your system, you just need to open JupyterLab, and when you create a new notebook, pick MariaDB as your kernel.
For some sample notebooks, check out the notebooks directory in our GitHub repository page. Those should guide through what you can do with mariadb_kernel.
You can also try mariadb_kernel using the amazing MyBinder platform by clicking this badge
or you can click on the Try MariaDB @ binder
badge from the mariadb_kernel GitHub repo.
This takes absolutely no effort except one click; Binder does everything for you! It sets up a MariaDB server and all the installation of the kernel and its requirements. Once this process is done, you will be redirected to a live notebook where you can type your commands.
Be aware that MyBinder does not save any state, whatever you change in a notebook in a session (unless you save the notebook locally yourself) will be lost once you close the page. We recommend using the MyBinder platform to try the MariaDB kernel when you quickly want to try a statement, if you'd like to see the latest features of the kernel in action or if you want to reproduce some results that a colleague has sent you. For all other use-cases we recommend you install the kernel and edit your notebooks locally.
Please be a bit patient when you launch MyBinder, the more people are clicking the MyBinder link, the higher the chances are that when you launch it, the Docker image of the kernel is already cached. If by any chance you see a Docker image building in the MyBinder logs, it shouldn't take more than a minute. Please be patient, if you wait one minute, it means you're helping all the other people launching the kernel after you to wait less! :-)
Below you'll find a table with all the available magic commands supported by the kernel.
For more help information regarding the usage and parameters of each magic command, please run the %lsmagic
command.
lsmagic
line
lists all available magic and help text for each
line
line
line-plots the result of the last query
df
line
write the result of the last query in a CSV file
bar
line
bar-plots the result of the last query
pie
line
pie-plots the result of the last query
load
line
loads the data from a CSV file into an existing table
delimiter
cell
run a SQL statement using a custom delimiter
Here's a list of the current restrictions and limitations of the MariaDB Jupyter kernel. Trying to stretch what we listed here is at your own risk, the results and the behavior of the kernel might be at the mercy of the universe :-)
One cell should only contain a single SQL statement. It can be multi-line, a one liner, it doesn't matter, but it needs to only be a single statement.
A notebook cell can only contain one line magic command (line magics start with %
). Everything else within the same cell below the line magic command will be ignored.
Magic commands and SQL statements cannot be mixed within the same notebook cell.
The kernel does not officially support the DELIMITER (MariaDB specific) client command. It might work, but it shouldn't be used. Rather use the %%delimiter
cell magic command (see %lsmagic
for usage information).
Each SQL statement within a notebook cell should end with the ;
MariaDB default delimiter, except in cells using the %%delimiter
cell magic command where it should end with the user-specified delimiter.
These features are the result of Xing-Zhi Jiang's work during Google Summer of Code 2021 and they are being fine-tuned and improved constantly to get a decent code completion and introspection experience in the MariaDB Jupyter Kernel.
The MariaDB Jupyter kernel is able to provide SQL autocompletion with a basic internal understanding of the context within your statements. We are trying to make the suggestions as precise as possible, but any SQL autocompletion is imperfect unless you either duplicate the entire grammar logic of MariaDB Server or the MariaDB Server itself develops mechanisms for external tools to poke into its parsing logic.
Autocompletion in Jupyter can be triggered with the key TAB
. In the classic Juptyter Notebook interface, it's possible to install some extensions to enable continuous hinting, but at the time this article is written there is no mechanism to enable continuous hinting in the new JupyterLab interface.
Here's a summary of our autocompletion capabilities, but we strongly recommend you play with the feature yourself and discover what it can do.
SQL keywords and functions completion
Completion of database names in USE
statements
Completion of database names in constructs like database_to_autocomplete.table_name
Completion of table names in constructs like db.table_name_to_autocomplete
Completion of column names in the WHERE
clause
Completion of column names in SELECT
queries
Completion of column names in INSERT
statements
Resolving aliases and completion of column names in constructs like alias.column_to_autocomplete
Completion of SHOW
statments
Completion of user accounts
Completion of global and session variables
Code introspection in Jupyter can be triggered with the SHIFT-TAB
combination.
This feature was designed to help you understand your database environment faster whilst typing SQL statements, for instance checking the table schema by inspecting on the table name before selecting a bunch of columns, or even checking the documentation of a SQL function to see the function signature and some practical examples and spare you an extra search on MariaDB Documentation.
Although we tried to make introspection look exactly the same in both classic Jupyter Notebook and Jupyterlab interfaces, it wasn't possible due to some fundamental difference in how Notebook renders the introspection tooltip in comparison to the newer JupyterLab interface.
For the moment, to see the full introspection information in Notebook that the MariaDB kernel sends to the frontend, you'll need to hit shift-tab
then click on the expand button from the tooltip to get the HTML
representation of the introspection information.
Here's a visual summary of our currently supported introspection capabilities.
Database introspection
Table schema and data summary
Column datatype and sample data
SQL function documentation and examples
User accounts introspection