API¶
This page contains a list of all functions and classes in MonetDBe-Python project (monetdbe).
Connection¶
This module contains the monetdbe connection class.
-
class
monetdbe.connection.
Connection
(database: Optional[Union[str, pathlib.Path]] = None, uri: bool = False, timeout: int = 0, detect_types: int = 0, check_same_thread: bool = True, autocommit: bool = False, nr_threads: int = 0, memorylimit: int = 0, querytimeout: int = 0, logging: Optional[pathlib.Path] = None, username: Optional[str] = None, password: Optional[str] = None, port: Optional[int] = None)¶ Bases:
object
-
exception
DataError
¶ Bases:
monetdbe.exceptions.DatabaseError
Exception raised for errors that are due to problems with the processed data like division by zero, numeric value out of range, etc. It must be a subclass of DatabaseError.
-
exception
DatabaseError
¶ Bases:
monetdbe.exceptions.Error
Exception raised for errors that are related to the database. It must be a subclass of Error.
-
exception
Error
¶ Bases:
Exception
Exception that is the base class of all other error exceptions. You can use this to catch all errors with one single ‘except’ statement. Warnings are not considered errors and thus should not use this class as base. It must be a subclass of the Python StandardError (defined in the module exceptions).
-
exception
IntegrityError
¶ Bases:
monetdbe.exceptions.DatabaseError
Exception raised when the relational integrity of the database is affected, e.g. a foreign key check fails. It must be a subclass of DatabaseError.
-
exception
InterfaceError
¶ Bases:
monetdbe.exceptions.Error
Exception raised for errors that are related to the database interface rather than the database itself. It must be a subclass of Error.
-
exception
InternalError
¶ Bases:
monetdbe.exceptions.DatabaseError
Exception raised when the database encounters an internal error, e.g. the cursor is not valid anymore, the transaction is out of sync, etc. It must be a subclass of DatabaseError.
-
exception
NotSupportedError
¶ Bases:
monetdbe.exceptions.DatabaseError
Exception raised in case a method or database API was used which is not supported by the database, e.g. requesting a .rollback() on a connection that does not support transaction or has transactions turned off. It must be a subclass of DatabaseError.
-
exception
OperationalError
¶ Bases:
monetdbe.exceptions.DatabaseError
Exception raised for errors that are related to the database’s operation and not necessarily under the control of the programmer, e.g. an unexpected disconnect occurs, the data source name is not found, a transaction could not be processed, a memory allocation error occurred during processing, etc. It must be a subclass of DatabaseError.
-
exception
ProgrammingError
¶ Bases:
monetdbe.exceptions.DatabaseError
Exception raised for programming errors, e.g. table not found or already exists, syntax error in the SQL statement, wrong number of parameters specified, etc. It must be a subclass of DatabaseError.
-
exception
Warning
¶ Bases:
Exception
Exception raised for important warnings like data truncations while inserting, etc. It must be a subclass of the Python StandardError (defined in the module exceptions).
-
backup
(*args, **kwargs)¶
-
close
(*args, **kwargs) → None¶
-
commit
(*args, **kwargs) → Cursor¶
-
create_aggregate
(*args, **kwargs)¶
-
create_collation
(*args, **kwargs)¶
-
create_function
(*args, **kwargs)¶
-
cursor
(factory: Optional[Type[Cursor]] = None) → Cursor¶ Create a new cursor.
- Parameters
factory – An optional factory. If supplied, this must be a callable returning an instance of Cursor or its subclasses.
- Returns
a new cursor.
-
execute
(query: str, args: Optional[Iterable] = None) → Cursor¶ Execute a SQL query
This is a nonstandard and SQLite compatible shortcut that creates a cursor object by calling the cursor() method, calls the cursor’s execute() method with the parameters given, and returns the cursor.
- Parameters
query – The SQL query to execute
args – The optional SQL query arguments
- Returns
A new cursor.
-
executemany
(query: str, args_seq: Union[Iterator, Iterable[Iterable]]) → Cursor¶ Prepare a database query and then execute it against all parameter sequences or mappings found in the sequence seq_of_parameters.
This is a nonstandard and SQLite compatible shortcut that creates a cursor object by calling the cursor() method, calls the cursor’s execute() method with the parameters given, and returns the cursor.
- Parameters
query – The SQL query to execute
args – The optional SQL query arguments
- Returns
A new cursor.
-
executescript
(sql_script: str)¶
-
property
in_transaction
¶
-
iterdump
(*args, **kwargs)¶
-
read_csv
(table, *args, **kwargs)¶
-
rollback
(*args, **kwargs)¶ Rolls back the current transaction.
-
set_autocommit
(value: bool) → None¶ Set the connection to auto-commit mode.
- Parameters
value – a boolean value
-
set_progress_handler
(*args, **kwargs)¶
-
set_trace_callback
(*args, **kwargs)¶
-
write_csv
(table, *args, **kwargs)¶
-
exception
Cursor¶
-
class
monetdbe.cursor.
Cursor
(con: monetdbe.connection.Connection)¶ Bases:
object
-
close
(*args, **kwargs)¶ Shut down the connection.
-
commit
() → monetdbe.cursor.Cursor¶ Commit the current pending transaction.
- Returns
the current cursor
-
create
(table, values, schema=None)¶ Creates a table from a set of values or a pandas DataFrame.
-
execute
(operation: str, parameters: Optional[Iterable] = None) → monetdbe.cursor.Cursor¶ Execute operation
- Parameters
operation – the query you want to execute
parameters – an optional iterable containing arguments for the operation.
- Returns
the cursor object itself
- Raises
OperationalError – if the execution failed
-
executemany
(operation: str, seq_of_parameters: Union[Iterator, Iterable[Iterable]]) → monetdbe.cursor.Cursor¶ Prepare a database operation (query or command) and then execute it against all parameter sequences or mappings found in the sequence seq_of_parameters.
- Parameters
operation – the SQL query to execute
seq_of_parameters – An optional iterator or iterable containing an iterable of arguments
-
executescript
(sql_script: str) → None¶ This is a nonstandard convenience and SQLite compatibility method for executing multiple SQL statements at once. It issues a COMMIT statement first, then executes the SQL script it gets as a parameter.
- Parameters
sql_script – A string containing one or more SQL statements, split by ;
- Raises
Error – If the previous call to .execute*() did not produce any result set or no call was issued yet.
-
fetchall
() → Iterable[Tuple[Any, Any]]¶ Fetch all (remaining) rows of a query result, returning them as a list of tuples).
- Returns
all (remaining) rows of a query result as a list of tuples
- Raises
Error – If the previous call to .execute*() did not produce any result set or no call was issued yet.
-
fetchdf
() → pandas.core.frame.DataFrame¶ Fetch all results and return a Pandas DataFrame.
like .fetchall(), but returns a Pandas DataFrame.
-
fetchmany
(size=None)¶ Fetch the next set of rows of a query result, returning a list of tuples). An empty sequence is returned when no more rows are available.
- Parameters
size – The number of rows to fetch. Fewer rows may be returned.
Returns: A number of rows from a query result as a list of tuples
- Raises
Error – If the previous call to .execute*() did not produce any result set or no call was issued yet.
-
fetchnumpy
() → numpy.ndarray¶ Fetch all results and return a numpy array.
like .fetchall(), but returns a numpy array.
-
fetchone
() → Optional[Tuple]¶ Fetch the next row of a query result set, returning a single tuple, or None when no more data is available.
- Returns
One row from a result set.
- Raises
Error – If the previous call to .execute*() did not produce any result set or no call was issued yet.
-
insert
(table: str, values: Union[pandas.core.frame.DataFrame, Dict[str, numpy.ndarray]], schema: str = 'sys')¶ Inserts a set of values into the specified table.
- Parameters
table – The table to insert into
values – The values. must be either a pandas DataFrame or a dictionary of values.
schema – The SQL schema to use. If no schema is specified, the “sys” schema is used.
-
lastrowid
= 0¶
-
read_csv
(table, *args, **kwargs)¶
-
scroll
(count: int, mode: str = 'relative')¶ Scroll the cursor in the result set to a new position according to mode.
We dont support scrolling, since the full result is available.
-
setinputsizes
(*args, **kwargs) → None¶ This method would normally be used before the .execute*() method is invoked to reserve memory.
MonetDBe-Python does not require this, so calling this function has no effect.
-
setoutputsize
(*args, **kwargs) → None¶ This method would normally set a column buffer size for fetchion of large columns.
MonetDBe-Python does not require this, so calling this function has no effect.
-
transaction
()¶ Start a new transaction
- Returns
the current cursor
-
write_csv
(table, *args, **kwargs)¶
-
-
class
monetdbe.cursor.
Description
(name, type_code, display_size, internal_size, precision, scale, null_ok)¶ Bases:
tuple
-
property
display_size
¶ Alias for field number 2
-
property
internal_size
¶ Alias for field number 3
-
property
name
¶ Alias for field number 0
-
property
null_ok
¶ Alias for field number 6
-
property
precision
¶ Alias for field number 4
-
property
scale
¶ Alias for field number 5
-
property
type_code
¶ Alias for field number 1
-
property
Row¶
-
class
monetdbe.row.
Row
(cur: monetdbe.cursor.Cursor, row: Union[tuple, Generator[Optional[Any], Any, None]])¶ Bases:
object
A Row is a non-standard SQLite compatible data container. It tries to mimic a tuple in most of its features.
It supports mapping access by column name and index, iteration, representation, equality testing and len().
If two Row objects have exactly the same columns and their members are equal, they compare equal.
-
keys
() → Tuple[Any]¶
-