API Reference

The set-up functions

dwopt.save_url

Save encoded database engine url to keyring or config.

dwopt.db

The database operator object factory.

dwopt.Db

Alias for dwopt.db()

dwopt.make_eng

Make database connection engine.

dwopt.make_test_tbl

Make or remake a test table on database.

Database operator object

dwopt.dbo._Db

The base database operator class.

Database operator object - operation methods

dwopt.dbo._Db.add_pkey

Make and run an add primary key statement.

dwopt.dbo._Db.create

Make and run a create table statment.

dwopt.dbo._Db.create_schema

Make and run a create schema statement.

dwopt.dbo._Db.cwrite

Create table and insert based on dataframe.

dwopt.dbo._Db.delete

WIP

dwopt.dbo._Db.drop

Drop table if exist.

dwopt.dbo._Db.exist

Check if table exist.

dwopt.dbo._Db.iris

Create the iris test table on the database.

dwopt.dbo._Db.mtcars

Create the mtcars test table on the database.

dwopt.dbo._Db.qry

Make a query object.

dwopt.dbo._Db.run

Run sql statement.

dwopt.dbo._Db.update

WIP

dwopt.dbo._Db.write

Make and run a insert many statement.

dwopt.dbo._Db.write_nodup

Insert without creating duplicates.

Database operator object - metadata methods

dwopt.dbo._Db.list_cons

List all constraints.

dwopt.dbo._Db.list_tables

List all tables on database or specified schema.

dwopt.dbo._Db.table_cols

Show information of specified table's columns.

dwopt.dbo._Db.table_sizes

List sizes of all tables in current schema.

Query object

dwopt._qry._Qry

The query class.

Query object - clause methods

dwopt._qry._Qry.case

Add a case when clause to the select clause.

dwopt._qry._Qry.from_

Add the from clause to query.

dwopt._qry._Qry.group_by

Add the group by clause to query.

dwopt._qry._Qry.having

Add the having clause to query.

dwopt._qry._Qry.join

Add a join clause to query.

dwopt._qry._Qry.order_by

Add the order by clause to query.

dwopt._qry._Qry.print

Print the built query.

dwopt._qry._Qry.run

Run the built query.

dwopt._qry._Qry.select

Add the select clause to query.

dwopt._qry._Qry.sql

Replace the underlying query by specified sql.

dwopt._qry._Qry.str

Return the built query as str.

dwopt._qry._Qry.where

Add the where clause to query.

Query object - summary methods

dwopt._qry._Qry.bin

WIP

dwopt._qry._Qry.cols

Fetch column names of the sub query table.

dwopt._qry._Qry.dist

Count number of distinct occurances of data.

dwopt._qry._Qry.five

WIP

dwopt._qry._Qry.hash

Calculate a simple oracle hash for table.

dwopt._qry._Qry.head

Fetch top 5 rows of the sub query table.

dwopt._qry._Qry.len

Length of the sub query table.

dwopt._qry._Qry.mimx

Fetch maximum and minimum values of a column.

dwopt._qry._Qry.pct

WIP

dwopt._qry._Qry.piv

WIP

dwopt._qry._Qry.top

Fetch top row of the sub query table.

dwopt._qry._Qry.valc

Value count of a column or combination of columns.