I've been trying to create custom magic for a Glue Studio Notebook, like the following example (taken from here)
I've adding the Ipython module by running the glue magic
%additional_python_modules IPython
And running this from a cell:
from IPython.core.magic import (register_line_magic,
register_cell_magic)
@register_line_magic
def hello(line):
if line == 'french':
print("Salut tout le monde!")
else:
print("Hello world!")
However, I get this error:
AttributeError: 'NoneType' object has no attribute 'register_magic_function'
Thanks.
I think is related to the fact that if i do
from IPython import get_ipython
get_ipython()
get_ipython() returns None.
This means that this is not running inside IPython, but what then? How can I add a custom magic? My goal is to have a magic to run sql queries in a postgresql database connected using a glue connection.