KAITITU Package¶
Subpackages
KAITITU is a library to deal with common tasks on databases. It has a generic API that helps on operational and analytical tasks for popular database management system.
- class kaititu.Database¶
Bases:
abc.ABCAbstract class for any specific vendor database. It manages queries to the database.
- __init__(srv: str, prt: int, usr: str, pwd: str, ins: str) None¶
Initializer
The user (usr) must have sufficient privileges to read system objects like tables and views.
- Parameters:
srv (str) – database host (IP/name)
prt (int) – database listen port
usr (str) – username
pwd (str) – username’s password
ins (str) – instance (database or service name)
- connect() sqlalchemy.engine.base.Connection¶
Get a connection for database.
Indeed, it’s a wrapper for connect method of
sqlalchemy.engine.Engineclass. However, it puts the ‘version’, ‘instance’ and ‘socket’ into the info property of connection.- Returns:
sqlalchemy.engine.Connection– connection for database
- property host: str¶
Get the database host
- Returns:
str – database host (name or IP address)
- property instance: str¶
Get the database name (for MSSQL, MySql, postgres and so on) or Service name (for Oracle)
- Returns:
str – database name or Service name
- property port: int¶
Get the database port number
- Returns:
int – database port number
- property socket: str¶
Get the current socket, representing host and port.
- Returns:
str – a socket - ‘host:port’
- property version: str¶
Get the database version as a banner
- Returns:
str – database version (verbose)
- class kaititu.MSSql¶
Bases:
kaititu.DatabaseAllow two ways of authentication, windows authentication and SQL Server authentication.
- __init__(srv: str, prt: int, usr: str = '', pwd: str = '', ins: str = 'master') None¶
Initializer
The user (usr) must have sufficient privileges to read system objects like tables and views.
- Parameters:
srv (str) – database host (IP/name)
prt (int) – database listen port
usr (str, optional) – username. Defaults to ‘’.
pwd (str, optional) – username’s password. Defaults to ‘’.
ins (str, optional) – database name. Defaults to “master”.
Note
Don’t provide usr and pwd for windows authentication.
- class kaititu.MySql¶
Bases:
kaititu.Database- __init__(srv: str, prt: int, usr: str, pwd: str, ins: str = 'mysql') None¶
Initializer
The user (usr) must have sufficient privileges to read system objects like tables and views.
- Parameters:
srv (str) – database host (IP/name)
prt (int) – database listen port
usr (str) – username
pwd (str) – username’s password
ins (str, optional) – database name. Defaults to “mysql”.
- class kaititu.Oracle¶
Bases:
kaititu.Database- __init__(srv: str, prt: int, usr: str, pwd: str, ins: str) None¶
Initializer
The user (usr) must have sufficient privileges to read system objects like tables and views.
- Parameters:
srv (str) – database host (IP/name)
prt (int) – database listen port
usr (str) – username
pwd (str) – username’s password
ins (str) – service name
- class kaititu.Postgres¶
Bases:
kaititu.Database- __init__(srv: str, prt: int, usr: str, pwd: str, ins: str = 'postgres') None¶
Initializer
The user (usr) must have sufficient privileges to read system objects like tables and views.
- Parameters:
srv (str) – database host (IP/name)
prt (int) – database listen port
usr (str) – username
pwd (str) – username’s password
ins (str, optional) – database name. Defaults to “postgres”.