Path: blob/main/singlestoredb/magics/__init__.py
469 views
from IPython.core.interactiveshell import InteractiveShell12from .run_personal import RunPersonalMagic3from .run_shared import RunSharedMagic45# In order to actually use these magics, we must register them with a6# running IPython.789def load_ipython_extension(ip: InteractiveShell) -> None:10"""11Any module file that define a function named `load_ipython_extension`12can be loaded via `%load_ext module.path` or be configured to be13autoloaded by IPython at startup time.14"""1516# Load jupysql extension17# This is necessary for jupysql to initialize internal state18# required to render messages19assert ip.extension_manager is not None20result = ip.extension_manager.load_extension('sql')21if result == 'no load function':22raise RuntimeError('Could not load sql extension. Is jupysql installed?')2324# Check if %run magic command is defined25if ip.find_line_magic('run') is None:26raise RuntimeError(27'%run magic command is not defined. '28'Is it available in your IPython environment?',29)3031# Register run_personal and run_shared32ip.register_magics(RunPersonalMagic(ip))33ip.register_magics(RunSharedMagic(ip))343536