module sql.magic_sql
¶
Short summary¶
module pyensae.sql.magic_sql
Defines SQL commands to play with sqlite3. See notebook SQL Magic Commands with SQLite in a Notebook.
Classes¶
class |
truncated documentation |
---|---|
Defines SQL commands to play with sqlite3 See notebook SQL Magic Commands with SQLite in a Notebook. … |
Functions¶
function |
truncated documentation |
---|---|
register magics function, can be called from a notebook |
Properties¶
property |
truncated documentation |
---|---|
|
return the context or None |
|
A contextmanager for running a block with our cross validation lock set to True. At the end of the block, … |
Static Methods¶
staticmethod |
truncated documentation |
---|---|
defines the way to parse the magic command |
|
defines the way to parse the magic command |
|
defines the way to parse the magic command |
|
defines the way to parse the magic command |
|
defines the way to parse the magic command |
|
defines the way to parse the magic command |
|
defines the way to parse the magic command |
|
defines the way to parse the magic command |
|
defines the way to parse the magic command |
|
defines the way to parse the magic command |
Methods¶
method |
truncated documentation |
---|---|
returns the connection stored in the workspace |
|
defines command |
|
defines |
|
define |
|
define |
|
defines |
|
defines |
|
defines |
|
defines |
|
define |
|
define |
Documentation¶
Defines SQL commands to play with sqlite3. See notebook SQL Magic Commands with SQLite in a Notebook.
- class pyensae.sql.magic_sql.MagicSQL(**kwargs: Any)¶
Bases:
MagicClassWithHelpers
Defines SQL commands to play with sqlite3 See notebook SQL Magic Commands with SQLite in a Notebook.
Create a configurable given a config config.
Parameters¶
- configConfig
If this is empty, default values are used. If config is a
Config
instance, it will be used to configure the instance.- parentConfigurable instance, optional
The parent Configurable instance of this object.
Notes¶
Subclasses of Configurable must call the
__init__()
method ofConfigurable
before doing anything else and usingsuper()
:class MyConfigurable(Configurable): def __init__(self, config=None): super(MyConfigurable, self).__init__(config=config) # Then any other code you need to finish initialization.
This ensures that instances will be configured properly.
- SQL(line, cell=None)¶
defines command
%%SQL
SQL
The code for magic command
%%SQL
is equivalent to:<variable> = db.execute(<cell>)
See notebook SQL Magic Commands with SQLite in a Notebook.
- SQL_add_function(line)¶
defines
%SQL_add_function
which adds a function to the databaseSQL_add_function
The code for magic command
%SQL_add_function
is equivalent to:db.add_function(fu)
See notebook SQL Magic Commands with SQLite in a Notebook.
- static SQL_add_function_parser()¶
defines the way to parse the magic command
%SQL_add_function
- SQL_close(line='')¶
define
SQL_close
which closes a databaseSQL_close
The code for magic command
%SQL_close
is equivalent to:db.close()
See notebook SQL Magic Commands with SQLite in a Notebook.
- static SQL_close_parser()¶
defines the way to parse the magic command
%SQL_close
- SQL_connect(line)¶
define
SQL_connect
which connects to a SQL database, it stores the database object in variable DB by defaultSQL_connect_parser
The code for magic command
%SQL_connect_parser
is equivalent to:from pyense.sql import InterfaceSQL obj = InterfaceSQL.create(args.filename) obj.connect()
See notebook SQL Magic Commands with SQLite in a Notebook.
- static SQL_connect_parser()¶
defines the way to parse the magic command
%SQL_connect
- SQL_drop_table(line)¶
defines
%SQL_drop_table
which drops a table from a databaseSQL_drop_table
The code for magic command
%SQL_drop_table
is equivalent to:db.drop_table()
See notebook SQL Magic Commands with SQLite in a Notebook.
- static SQL_drop_table_parser()¶
defines the way to parse the magic command
%SQL_drop_table
- SQL_import_df(line)¶
defines
%SQL_import_df
which imports a dataframe into a databaseSQL_import_df
The code for magic command
%SQL_import_df
is equivalent to:db.import_dataframe(<table>, <df>)
See notebook SQL Magic Commands with SQLite in a Notebook.
- static SQL_import_df_parser()¶
defines the way to parse the magic command
%SQL_import_df
- SQL_import_tsv(line)¶
defines
%SQL_import_tsv
whichs import a TSV file into a databaseSQL_import_tsv
The code for magic command
%SQL_import_tsv
is equivalent to:db.import_flat_file(<filename>, <table>)
See notebook SQL Magic Commands with SQLite in a Notebook.
- static SQL_import_tsv_parser()¶
defines the way to parse the magic command
%SQL_import_tsv
- static SQL_parser()¶
defines the way to parse the magic command
%%SQL
- SQL_refresh_completion(line='')¶
defines
%SQL_refresh_completion
- static SQL_refresh_completion_parser()¶
defines the way to parse the magic command
%SQL_refresh_completion
- SQL_schema(line='')¶
define
SQL_schema
SQL_schema
The code for magic command
%SQL_schema
is equivalent to:db.get_table_columns(<table>, as_dict=not <as_list>)
See notebook SQL Magic Commands with SQLite in a Notebook.
- static SQL_schema_parser()¶
defines the way to parse the magic command
%SQL_schema
- SQL_tables(line='')¶
define
%SQL_tables
whichs lists the tables in a databaseSQL_tables
The code for magic command
%SQL_tables
is equivalent to:db.get_table_list()
See notebook SQL Magic Commands with SQLite in a Notebook.
- static SQL_tables_parser()¶
defines the way to parse the magic command
%SQL_tables
- _all_trait_default_generators: Dict[str, Any] = {'config': <bound method TraitType.default of <traitlets.traitlets.Instance object>>, 'parent': <bound method TraitType.default of <traitlets.traitlets.Instance object>>}¶
- _descriptors = [<traitlets.traitlets.ObserveHandler object>, <traitlets.traitlets.Instance object>, <traitlets.traitlets.Instance object>]¶
- _instance_inits = [<bound method ObserveHandler.instance_init of <traitlets.traitlets.ObserveHandler object>>, <bound method Instance.instance_init of <traitlets.traitlets.Instance object>>, <bound method Instance.instance_init of <traitlets.traitlets.Instance object>>]¶
- _trait_default_generators = {}¶
- _traits: Dict[str, Any] = {'config': <traitlets.traitlets.Instance object>, 'parent': <traitlets.traitlets.Instance object>}¶
- get_connection(name)¶
returns the connection stored in the workspace
- Parameters:
name – variable name of the database
- Returns:
object
- pyensae.sql.magic_sql.register_sql_magics(ip=None)¶
register magics function, can be called from a notebook
- Parameters:
ip – from
get_ipython()