module sql.magic_sql

Inheritance diagram of pyensae.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.

source on GitHub

Classes

class

truncated documentation

MagicSQL

Defines SQL commands to play with sqlite3 See notebook SQL Magic Commands with SQLite in a Notebook. …

Functions

function

truncated documentation

register_sql_magics

register magics function, can be called from a notebook

Properties

property

truncated documentation

Context

return the context or None

cross_validation_lock

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

SQL_add_function_parser

defines the way to parse the magic command %SQL_add_function

SQL_close_parser

defines the way to parse the magic command %SQL_close

SQL_connect_parser

defines the way to parse the magic command %SQL_connect

SQL_drop_table_parser

defines the way to parse the magic command %SQL_drop_table

SQL_import_df_parser

defines the way to parse the magic command %SQL_import_df

SQL_import_tsv_parser

defines the way to parse the magic command %SQL_import_tsv

SQL_parser

defines the way to parse the magic command %%SQL

SQL_refresh_completion_parser

defines the way to parse the magic command %SQL_refresh_completion

SQL_schema_parser

defines the way to parse the magic command %SQL_schema

SQL_tables_parser

defines the way to parse the magic command %SQL_tables

Methods

method

truncated documentation

get_connection

returns the connection stored in the workspace

SQL

defines command %%SQL

SQL_add_function

defines %SQL_add_function which adds a function to the database

SQL_close

define SQL_close which closes a database

SQL_connect

define SQL_connect which connects to a SQL database, it stores the database object in variable DB by default …

SQL_drop_table

defines %SQL_drop_table which drops a table from a database

SQL_import_df

defines %SQL_import_df which imports a dataframe into a database

SQL_import_tsv

defines %SQL_import_tsv whichs import a TSV file into a database

SQL_refresh_completion

defines %SQL_refresh_completion

SQL_schema

define SQL_schema

SQL_tables

define %SQL_tables whichs lists the tables in a database

Documentation

Defines SQL commands to play with sqlite3. See notebook SQL Magic Commands with SQLite in a Notebook.

source on GitHub

class pyensae.sql.magic_sql.MagicSQL(shell=None, **kwargs)[source]

Bases: pyquickhelper.ipythonhelper.magic_class.MagicClassWithHelpers

Defines SQL commands to play with sqlite3 See notebook SQL Magic Commands with SQLite in a Notebook.

source on GitHub

SQL(line, cell=None)[source]

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.

source on GitHub

SQL_add_function(line)[source]

defines %SQL_add_function which adds a function to the database

SQL_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.

source on GitHub

static SQL_add_function_parser()[source]

defines the way to parse the magic command %SQL_add_function

source on GitHub

SQL_close(line='')[source]

define SQL_close which closes a database

SQL_close

The code for magic command %SQL_close is equivalent to:

db.close()

See notebook SQL Magic Commands with SQLite in a Notebook.

source on GitHub

static SQL_close_parser()[source]

defines the way to parse the magic command %SQL_close

source on GitHub

SQL_connect(line)[source]

define SQL_connect which connects to a SQL database, it stores the database object in variable DB by default

SQL_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.

source on GitHub

static SQL_connect_parser()[source]

defines the way to parse the magic command %SQL_connect

source on GitHub

SQL_drop_table(line)[source]

defines %SQL_drop_table which drops a table from a database

SQL_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.

source on GitHub

static SQL_drop_table_parser()[source]

defines the way to parse the magic command %SQL_drop_table

source on GitHub

SQL_import_df(line)[source]

defines %SQL_import_df which imports a dataframe into a database

SQL_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.

source on GitHub

static SQL_import_df_parser()[source]

defines the way to parse the magic command %SQL_import_df

source on GitHub

SQL_import_tsv(line)[source]

defines %SQL_import_tsv whichs import a TSV file into a database

SQL_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.

source on GitHub

static SQL_import_tsv_parser()[source]

defines the way to parse the magic command %SQL_import_tsv

source on GitHub

static SQL_parser()[source]

defines the way to parse the magic command %%SQL

source on GitHub

SQL_refresh_completion(line='')[source]

defines %SQL_refresh_completion

source on GitHub

static SQL_refresh_completion_parser()[source]

defines the way to parse the magic command %SQL_refresh_completion

source on GitHub

SQL_schema(line='')[source]

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.

source on GitHub

static SQL_schema_parser()[source]

defines the way to parse the magic command %SQL_schema

source on GitHub

SQL_tables(line='')[source]

define %SQL_tables whichs lists the tables in a database

SQL_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.

source on GitHub

static SQL_tables_parser()[source]

defines the way to parse the magic command %SQL_tables

source on GitHub

_trait_default_generators = {}
get_connection(name)[source]

returns the connection stored in the workspace

Parameters

name – variable name of the database

Returns

object

source on GitHub

pyensae.sql.magic_sql.register_sql_magics(ip=None)[source]

register magics function, can be called from a notebook

Parameters

ip – from get_ipython()

source on GitHub