Package osh :: Package command :: Module sql
[frames] | no frames]

Module sql

source code

sql [DB] QUERY

Executes a sql query on a specified database. Occurrences of formatting directives (e.g. %s) will be replaced by input values.

The database is selected by DB. If DB matches an osh.sql profile in .oshrc, then the database is specified by that profile. If DB is omitted, then the default profile is used.

If QUERY is a SELECT statement, then the query is executed and output rows, represented by tuples, are written to output. If QUERY is any other type of SQL statement, then no output is written.

Functions
 
sql(query, db=None)
Executes a sql query on a specified database.
source code
Function Details

sql(query, db=None)

source code 

Executes a sql query on a specified database. Occurrences of formatting directives (e.g. %s) will be replaced by input values. The database is selected by db. If db matches an osh.sql profile in .oshrc, then the database is specified by that profile. If db is None, then the default profile is used. If QUERY is a select statement, then the query is executed and output rows, represented by tuples, are written to output. If QUERY is any other type of SQL statement, then no output is written.