ll.orasql – Utilities for cx_Oracle

ll.orasql contains utilities for working with cx_Oracle:

  • It allows calling procedures and functions with keyword arguments (via the classes Procedure and Function).

  • Query results will be put into Record objects, where database fields are accessible as object attributes.

  • The Connection class provides methods for iterating through the database metadata.

  • Importing this module adds support for URLs with the scheme oracle to ll.url. Examples of these URLs are:

    oracle://user:pwd@db/
    oracle://user:pwd@db/view/
    oracle://user:pwd@db/view/USER_TABLES.sql
    oracle://sys:pwd:sysdba@db/
    
exception ll.orasql.SQLObjectNotFoundError(obj)[source]

Bases: OSError

exception ll.orasql.SQLNoSuchObjectError(name, owner)[source]

Bases: Exception

exception ll.orasql.UnknownModeError(mode)[source]

Bases: ValueError

exception ll.orasql.ConflictError(object, message)[source]

Bases: ValueError

class ll.orasql.Args(arg=None, **kwargs)[source]

Bases: dict

An Args object is a subclass of dict that is used for passing arguments to procedures and functions. Both item and attribute access (i.e. __getitem__() and __getattr__()) are available. Names are case insensitive.

update([E, ]**F) → None. Update D from dict/iterable E and F.[source]

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

__getitem__(name)[source]

x.__getitem__(y) <==> x[y]

__setitem__(name, value)[source]

Set self[key] to value.

__delitem__(name)[source]

Delete self[key].

class ll.orasql.LOBStream(value)[source]

Bases: object

A LOBStream object provides streamlike access to a BLOB or CLOB.

readall()[source]

Read all remaining data from the stream and return it.

readchunk()[source]

Read a chunk of data from the stream and return it. Reading is done in optimally sized chunks.

read(size=None)[source]

Read size bytes/characters from the stream and return them. If size is None all remaining data will be read.

reset()[source]

Reset the stream so that the next read() call starts at the beginning of the LOB.

seek(offset, whence=0)[source]

Seek to the position offset in the LOB. The whence argument is optional and defaults to 0 (absolute file positioning); The other allowed value is 1 (seek relative to the current position).

class ll.orasql.Record[source]

Bases: tuple, collections.abc.Mapping

A Record is a subclass of tuple that is used for storing results of database fetches and procedure and function calls. Both item and attribute access (i.e. __getitem__() and __getattr__()) are available. Field names are case insensitive.

__getitem__(arg)[source]

Return self[key].

get(name, default=None)[source]

Return the value for the field named name. If this field doesn’t exist in self, return default instead.

__contains__(name)[source]

Return key in self.

keys()[source]

Return an iterator over field names.

items()[source]

Return an iterator over (field name, field value) tuples.

replace(**kwargs)[source]

Return a new Record with the same fields as self, except for those fields given new values by whichever keyword arguments are specified.

class ll.orasql.SessionPool(user, password, database, min, max, increment, connectiontype=None, threaded=False, getmode=1, homogeneous=True)[source]

Bases: cx_Oracle.SessionPool

SessionPool is a subclass of cx_Oracle.SessionPool.

ll.orasql.owned(obj, owner)[source]

Do we own the object obj according to the owner specification owner?

owner can be:

None

The current user (i.e. via the view USER_OBJECTS);

ALL

Any user (via the views ALL_OBJECTS or DBA_OBJECTS);

usernamestring

The specified user

set or tuple

A set or tuple of usernames. An object must belong to any of the users to be considered owned.

class ll.orasql.Connection(*args, **kwargs)[source]

Bases: cx_Oracle.Connection

Connection is a subclass of cx_Oracle.Connection.

cursor(readlobs=None)[source]

Return a new cursor for this connection. For the meaning of readlobs see __init__().

tables(owner=None, mode='flat')[source]

Generator that yields all table definitions in the current users schema (or all users schemas). mode specifies the order in which tables will be yielded:

"create"

Create order, inserting records into the table in this order will not violate foreign key constraints.

"drop"

Drop order, deleting records from the table in this order will not violate foreign key constraints.

"flat"

Unordered.

owner specifies from which user tables should be yielded. It can be None (for the current user), ALL (for all users (the default)) or a user name.

Tables that are materialized views will be skipped in all cases.

sequences(owner=None)[source]

Generator that yields sequences. owner can be None (the default), ALL or a user name.

fks(owner=None)[source]

Generator that yields all foreign key constraints. owner can be None (the default), ALL or a user name.

privileges(owner=None)[source]

Generator that yields object privileges. owner can be None (the default), ALL, a user name or a set or tuple of user names.

synonyms(owner=None, object_owner=ll.orasql.ALL)[source]

Generator that yields synonyms. owner and object_owner can be None (the default), ALL, a user name or a set or tuple of user names.

users()[source]

Generator that yields all users.

objects(owner=None, mode='create')[source]

Generator that yields the sequences, tables, primary keys, foreign keys, comments, unique constraints, indexes, views, functions, procedures, packages, types and jobsin the current users schema (or all users schemas) in a specified order.

mode specifies the order in which objects will be yielded:

"create"

Create order, i.e. recreating the objects in this order will not lead to errors;

"drop"

Drop order, i.e. dropping the objects in this order will not lead to errors;

"flat"

Unordered.

owner specifies from which schema objects should be yielded. For more information see owned().

getobject(name, owner=None)[source]

Return the object named name from the schema. If owner is None the current schema is queried, else the specified one is used. name and owner are treated case insensitively.

ll.orasql.connect(*args, **kwargs)[source]

Create a connection to the database and return a Connection object.

class ll.orasql.Cursor(connection, readlobs=None)[source]

Bases: cx_Oracle.Cursor

A subclass of the cursor class in cx_Oracle. The “fetch” methods will return records as Record objects and LOB values will be returned as LOBStream objects or str/bytes objects (depending on the cursors readlobs attribute).

ddprefix()[source]

Return whether the user has access to the DBA_* views ("dba") or not ("all").

ddprefixargs()[source]

Return whether the user has access to the DBA_ARGUMENTS view ("dba") or not ("all").

class ll.orasql.MixinNormalDates[source]

Bases: object

Mixin class that provides methods for determining creation and modification dates for objects.

class ll.orasql.MixinCodeSQL[source]

Bases: object

Mixin class that provides methods returning the create and drop statements for various objects.

class ll.orasql.SchemaObject(name, connection=None)[source]

Bases: object

The base class for all Python classes modelling schema objects in the database.

createsql(connection=None, term=True)[source]

Return SQL code to create this object.

dropsql(connection=None, term=True)[source]

Return SQL code to drop this object

fixname(code)[source]

Replace the name of the object in the SQL code code with the name of self.

exists(connection=None)[source]

Return whether the object self really exists in the database specified by connection.

cdate(connection=None)[source]

Return a datetime.datetime object with the creation date of self in the database specified by connection (or None if that information is not available).

udate(connection=None)[source]

Return a datetime.datetime object with the last modification date of self in the database specified by connection (or None if that information is not available).

references(connection=None, done=None)[source]

Objects directly used by self.

If connection is not None it will be used as the database connection from which to fetch data. If connection is None the connection from which self has been extracted will be used. If there is not such connection, you’ll get an exception.

referencesall(connection=None, done=None)[source]

All objects used by self (recursively).

For the meaning of connection see references().

done is used internally and shouldn’t be passed.

referencedby(connection=None)[source]

Objects using self.

For the meaning of connection see references().

referencedbyall(connection=None, done=None)[source]

All objects depending on self (recursively).

For the meaning of connection see references().

done is used internally and shouldn’t be passed.

class ll.orasql.OwnedSchemaObject(name, owner=None, connection=None)[source]

Bases: ll.orasql.SchemaObject

The base class for all Python classes modelling schema objects in the database.

references(connection=None)[source]

Objects directly used by self.

If connection is not None it will be used as the database connection from which to fetch data. If connection is None the connection from which self has been extracted will be used. If there is not such connection, you’ll get an exception.

referencedby(connection=None)[source]

Objects using self.

For the meaning of connection see references().

classmethod names(connection, owner=None)[source]

Generator that yields the names of all objects of this type. The argument owner specifies whose objects are yielded. For more information see owned().

Names will be in ascending order.

classmethod objects(connection, owner=None)[source]

Generator that yields all objects of this type in the current users schema. The argument owner specifies whose objects are yielded. For more information see owned().

synonyms(connection=None)[source]

Generator the yields all synonyms for this object.

privileges(connection=None)[source]

Generator the yields all privileges on this object.

class ll.orasql.Sequence(name, owner=None, connection=None)[source]

Bases: ll.orasql.MixinNormalDates, ll.orasql.OwnedSchemaObject

Models a sequence in the database.

exists(connection=None)[source]

Return whether the object self really exists in the database specified by connection.

createsql(connection=None, term=True)[source]

Return SQL code to create this object.

createsqlcopy(connection=None, term=True)[source]

Return SQL code to create an identical copy of this sequence.

dropsql(connection=None, term=True)[source]

Return SQL code to drop this object

fixname(code)[source]

Replace the name of the object in the SQL code code with the name of self.

references(connection=None, done=None)[source]

Objects directly used by self.

If connection is not None it will be used as the database connection from which to fetch data. If connection is None the connection from which self has been extracted will be used. If there is not such connection, you’ll get an exception.

class ll.orasql.Table(name, owner=None, connection=None)[source]

Bases: ll.orasql.MixinNormalDates, ll.orasql.OwnedSchemaObject

Models a table in the database.

createsql(connection=None, term=True)[source]

Return SQL code to create this object.

exists(connection=None)[source]

Return whether the object self really exists in the database specified by connection.

dropsql(connection=None, term=True)[source]

Return SQL code to drop this object

fixname(code)[source]

Replace the name of the object in the SQL code code with the name of self.

mview(connection=None)[source]

The materialized view this table belongs to (or None if it’s a real table).

ismview(connection=None)[source]

Is this table a materialized view?

organization(connection=None)[source]

Return the organization of this table: either "heap" (for “normal” tables) or "index" (for index organized tables).

logging(connection=None)[source]

Return whether to table is in logging mode or not.

classmethod names(connection, owner=None)[source]

Generator that yields the names of all objects of this type. The argument owner specifies whose objects are yielded. For more information see owned().

Names will be in ascending order.

columns(connection=None)[source]

Generator that yields all column objects of this table.

records(connection=None)[source]

Generator that yields all records of this table.

comments(connection=None)[source]

Generator that yields all column comments of this table.

constraints(connection=None)[source]

Generator that yields all constraints for this table.

pk(connection=None)[source]

Return the primary key constraint for this table (or None if the table has no primary key constraint).

references(connection=None)[source]

Objects directly used by self.

If connection is not None it will be used as the database connection from which to fetch data. If connection is None the connection from which self has been extracted will be used. If there is not such connection, you’ll get an exception.

referencedby(connection=None)[source]

Objects using self.

For the meaning of connection see references().

class ll.orasql.Comment(name, owner=None, connection=None)[source]

Bases: ll.orasql.OwnedSchemaObject

Models a column comment in the database.

exists(connection=None)[source]

Return whether the object self really exists in the database specified by connection.

comment(connection=None)[source]

Return the comment text for this column.

createsql(connection=None, term=True)[source]

Return SQL code to create this object.

dropsql(connection=None, term=True)[source]

Return SQL code to drop this object

fixname(code)[source]

Replace the name of the object in the SQL code code with the name of self.

references(connection=None)[source]

Objects directly used by self.

If connection is not None it will be used as the database connection from which to fetch data. If connection is None the connection from which self has been extracted will be used. If there is not such connection, you’ll get an exception.

class ll.orasql.Constraint(name, owner=None, connection=None)[source]

Bases: ll.orasql.OwnedSchemaObject

Base class of all constraints (primary key constraints, foreign key constraints, unique constraints and check constraints).

exists(connection=None)[source]

Return whether the object self really exists in the database specified by connection.

cdate(connection=None)[source]

Return a datetime.datetime object with the creation date of self in the database specified by connection (or None if that information is not available).

udate(connection=None)[source]

Return a datetime.datetime object with the last modification date of self in the database specified by connection (or None if that information is not available).

dropsql(connection=None, term=True)[source]

Return SQL code to drop this object

isenabled(connection=None)[source]

Return whether this constraint is enabled.

classmethod names(connection, owner=None)[source]

Generator that yields the names of all objects of this type. The argument owner specifies whose objects are yielded. For more information see owned().

Names will be in ascending order.

fixname(code)[source]

Replace the name of the object in the SQL code code with the name of self.

table(connection=None)[source]

Return the Table self belongs to.

class ll.orasql.PrimaryKey(name, owner=None, connection=None)[source]

Bases: ll.orasql.Constraint

Models a primary key constraint in the database.

columns(connection=None)[source]

Return an iterator over the columns this primary key consists of.

createsql(connection=None, term=True)[source]

Return SQL code to create this object.

referencedby(connection=None)[source]

Objects using self.

For the meaning of connection see references().

references(connection=None)[source]

Objects directly used by self.

If connection is not None it will be used as the database connection from which to fetch data. If connection is None the connection from which self has been extracted will be used. If there is not such connection, you’ll get an exception.

class ll.orasql.ForeignKey(name, owner=None, connection=None)[source]

Bases: ll.orasql.Constraint

Models a foreign key constraint in the database.

createsql(connection=None, term=True)[source]

Return SQL code to create this object.

referencedby(connection=None)[source]

Objects using self.

For the meaning of connection see references().

references(connection=None)[source]

Objects directly used by self.

If connection is not None it will be used as the database connection from which to fetch data. If connection is None the connection from which self has been extracted will be used. If there is not such connection, you’ll get an exception.

refconstraint(connection=None)[source]

Return the constraint referenced by self.

In most cases this is a PrimaryKey, but it also might be a UniqueConstraint.

columns(connection=None)[source]

Return an iterator over the columns this foreign key consists of.

class ll.orasql.UniqueConstraint(name, owner=None, connection=None)[source]

Bases: ll.orasql.Constraint

Models a unique constraint in the database.

createsql(connection=None, term=True)[source]

Return SQL code to create this object.

referencedby(connection=None)[source]

Objects using self.

For the meaning of connection see references().

references(connection=None)[source]

Objects directly used by self.

If connection is not None it will be used as the database connection from which to fetch data. If connection is None the connection from which self has been extracted will be used. If there is not such connection, you’ll get an exception.

class ll.orasql.CheckConstraint(name, owner=None, connection=None)[source]

Bases: ll.orasql.Constraint

Models a check constraint in the database.

createsql(connection=None, term=True)[source]

Return SQL code to create this object.

referencedby(connection=None)[source]

Objects using self.

For the meaning of connection see references().

references(connection=None)[source]

Objects directly used by self.

If connection is not None it will be used as the database connection from which to fetch data. If connection is None the connection from which self has been extracted will be used. If there is not such connection, you’ll get an exception.

class ll.orasql.Index(name, owner=None, connection=None)[source]

Bases: ll.orasql.MixinNormalDates, ll.orasql.OwnedSchemaObject

Models an index in the database.

exists(connection=None)[source]

Return whether the object self really exists in the database specified by connection.

createsql(connection=None, term=True)[source]

Return SQL code to create this object.

dropsql(connection=None, term=True)[source]

Return SQL code to drop this object

rebuildsql(connection=None, term=True)[source]

Return SQL code to rebuild this index.

classmethod names(connection, owner=None)[source]

Generator that yields the names of all objects of this type. The argument owner specifies whose objects are yielded. For more information see owned().

Names will be in ascending order.

fixname(code)[source]

Replace the name of the object in the SQL code code with the name of self.

constraint(connection=None)[source]

If this index is generated by a constraint, return the constraint otherwise return None.

isconstraint(connection=None)[source]

Is this index generated by a constraint?

references(connection=None)[source]

Objects directly used by self.

If connection is not None it will be used as the database connection from which to fetch data. If connection is None the connection from which self has been extracted will be used. If there is not such connection, you’ll get an exception.

table(connection=None)[source]

Return the Table self belongs to.

columns(connection=None)[source]

Return an iterator over the columns this index consists of.

class ll.orasql.Synonym(name, owner=None, connection=None)[source]

Bases: ll.orasql.OwnedSchemaObject

Models a synonym in the database.

exists(connection=None)[source]

Return whether the object self really exists in the database specified by connection.

createsql(connection=None, term=True)[source]

Return SQL code to create this object.

dropsql(connection=None, term=True)[source]

Return SQL code to drop this object

fixname(code)[source]

Replace the name of the object in the SQL code code with the name of self.

object(connection=None)[source]

Return the object for which self is a synonym.

classmethod names(connection, owner=None, object_owner=ll.orasql.ALL)[source]

Generator that yields the names of all synonyms. For the meaning of owner and object_owner see objects().

Names will be in ascending order.

classmethod objects(connection, owner=None, object_owner=ll.orasql.ALL)[source]

Generator that yields all synonym in the current users schema. The argument owner specifies to which owner the synonym must belong to to be yielded. The argument object_owner specifies to which owner the object must belong to to be yielded. For more information see owned().

class ll.orasql.View(name, owner=None, connection=None)[source]

Bases: ll.orasql.MixinNormalDates, ll.orasql.OwnedSchemaObject

Models a view in the database.

exists(connection=None)[source]

Return whether the object self really exists in the database specified by connection.

createsql(connection=None, term=True)[source]

Return SQL code to create this object.

dropsql(connection=None, term=True)[source]

Return SQL code to drop this object

fixname(code)[source]

Replace the name of the object in the SQL code code with the name of self.

class ll.orasql.MaterializedView(name, owner=None, connection=None)[source]

Bases: ll.orasql.View

Models a meterialized view in the database.

exists(connection=None)[source]

Return whether the object self really exists in the database specified by connection.

createsql(connection=None, term=True)[source]

Return SQL code to create this object.

dropsql(connection=None, term=True)[source]

Return SQL code to drop this object

fixname(code)[source]

Replace the name of the object in the SQL code code with the name of self.

references(connection=None)[source]

Objects directly used by self.

If connection is not None it will be used as the database connection from which to fetch data. If connection is None the connection from which self has been extracted will be used. If there is not such connection, you’ll get an exception.

referencedby(connection=None)[source]

Objects using self.

For the meaning of connection see references().

class ll.orasql.Library(name, owner=None, connection=None)[source]

Bases: ll.orasql.OwnedSchemaObject

Models a library in the database.

exists(connection=None)[source]

Return whether the object self really exists in the database specified by connection.

createsql(connection=None, term=True)[source]

Return SQL code to create this object.

dropsql(connection=None, term=True)[source]

Return SQL code to drop this object

fixname(code)[source]

Replace the name of the object in the SQL code code with the name of self.

class ll.orasql.Argument(name, position, datatype, isin, isout)[source]

Bases: object

Argument objects hold information about the arguments of a stored procedure.

class ll.orasql.Callable(name, owner=None, connection=None)[source]

Bases: ll.orasql.MixinNormalDates, ll.orasql.MixinCodeSQL, ll.orasql.OwnedSchemaObject

Models a callable object in the database, i.e. functions and procedures.

arguments(connection=None)[source]

Generator that yields all arguments of the function/procedure self.

synonyms(connection=None)[source]

Generator the yields all synonyms for this object.

privileges(connection=None)[source]

Generator the yields all privileges on this object.

class ll.orasql.Procedure(name, owner=None, connection=None)[source]

Bases: ll.orasql.Callable

Models a procedure in the database. A Procedure object can be used as a wrapper for calling the procedure with keyword arguments.

__call__(cursor, *args, **kwargs)[source]

Call the procedure with arguments args and keyword arguments kwargs. cursor must be a ll.orasql.Cursor object. This will return a Record object containing the result of the call (i.e. this record will contain all specified and all out parameters).

class ll.orasql.Function(name, owner=None, connection=None)[source]

Bases: ll.orasql.Callable

Models a function in the database. A Function object can be used as a wrapper for calling the function with keyword arguments.

__call__(cursor, *args, **kwargs)[source]

Call the function with arguments args and keyword arguments kwargs. cursor must be an ll.orasql.Cursor object. This will return a tuple containing the result and a Record object containing the modified parameters (i.e. this record will contain all specified and out parameters).

class ll.orasql.Package(name, owner=None, connection=None)[source]

Bases: ll.orasql.MixinNormalDates, ll.orasql.MixinCodeSQL, ll.orasql.OwnedSchemaObject

Models a package in the database.

class ll.orasql.PackageBody(name, owner=None, connection=None)[source]

Bases: ll.orasql.MixinNormalDates, ll.orasql.MixinCodeSQL, ll.orasql.OwnedSchemaObject

Models a package body in the database.

synonyms(connection=None)[source]

Generator the yields all synonyms for this object.

privileges(connection=None)[source]

Generator the yields all privileges on this object.

class ll.orasql.Type(name, owner=None, connection=None)[source]

Bases: ll.orasql.MixinNormalDates, ll.orasql.MixinCodeSQL, ll.orasql.OwnedSchemaObject

Models a type definition in the database.

class ll.orasql.TypeBody(name, owner=None, connection=None)[source]

Bases: ll.orasql.MixinNormalDates, ll.orasql.MixinCodeSQL, ll.orasql.OwnedSchemaObject

Models a type body in the database.

synonyms(connection=None)[source]

Generator the yields all synonyms for this object.

privileges(connection=None)[source]

Generator the yields all privileges on this object.

class ll.orasql.Trigger(name, owner=None, connection=None)[source]

Bases: ll.orasql.MixinNormalDates, ll.orasql.MixinCodeSQL, ll.orasql.OwnedSchemaObject

Models a trigger in the database.

class ll.orasql.JavaSource(name, owner=None, connection=None)[source]

Bases: ll.orasql.MixinNormalDates, ll.orasql.OwnedSchemaObject

Models Java source code in the database.

exists(connection=None)[source]

Return whether the object self really exists in the database specified by connection.

createsql(connection=None, term=True)[source]

Return SQL code to create this object.

dropsql(connection=None, term=True)[source]

Return SQL code to drop this object

fixname(code)[source]

Replace the name of the object in the SQL code code with the name of self.

class ll.orasql.Privilege(privilege, name, grantor, grantee, owner=None, connection=None)[source]

Bases: object

Models a database object privilege (i.e. a grant).

A Privilege object has the following attributes:

privilegestring

The type of the privilege (EXECUTE etc.)

namestring

The name of the object for which this privilege grants access

ownerstring or None

the owner of the object

grantorstring or None

Who granted this privilege?

granteestring or None

To whom has this privilege been granted?

connectionConnection or None

The database connection

object(connection=None)[source]

Return the object on which self grants a privilege.

classmethod objects(connection, owner=None)[source]

Generator that yields object privileges. For the meaning of owner see owned().

grantsql(connection=None, term=True, mapgrantee=True)[source]

Return SQL code to grant this privilege. If mapgrantee is a list or a dictionary and self.grantee is not in this list (or dictionary) no command will be returned. If it’s a dictionary and self.grantee is in it, the privilege will be granted to the user specified as the value instead of the original one. If mapgrantee is true (the default) the privilege will be granted to the original grantee.

class ll.orasql.Column(name, owner=None, connection=None)[source]

Bases: ll.orasql.OwnedSchemaObject

Models a single column of a table in the database. This is used to output ALTER TABLE statements for adding, dropping and modifying columns.

exists(connection=None)[source]

Return whether the object self really exists in the database specified by connection.

dropsql(connection=None, term=True)[source]

Return SQL code to drop this object

cdate(connection=None)[source]

Return a datetime.datetime object with the creation date of self in the database specified by connection (or None if that information is not available).

udate(connection=None)[source]

Return a datetime.datetime object with the last modification date of self in the database specified by connection (or None if that information is not available).

references(connection=None)[source]

Objects directly used by self.

If connection is not None it will be used as the database connection from which to fetch data. If connection is None the connection from which self has been extracted will be used. If there is not such connection, you’ll get an exception.

datatype(connection=None)[source]

The SQL type of this column.

default(connection=None)[source]

The SQL default value for this column.

nullable(connection=None)[source]

Is this column nullable?

comment(connection=None)[source]

The comment for this column.

synonyms(connection=None)[source]

Generator the yields all synonyms for this object.

privileges(connection=None)[source]

Generator the yields all privileges on this object.

class ll.orasql.User(name, connection=None)[source]

Bases: ll.orasql.SchemaObject

Models a user in the database.

exists(connection=None)[source]

Return whether the object self really exists in the database specified by connection.

classmethod names(connection)[source]

Generator that yields the names of all users in ascending order

classmethod objects(connection)[source]

Generator that yields all user objects.

class ll.orasql.Preference(name, owner=None, connection=None)[source]

Bases: ll.orasql.OwnedSchemaObject

Models a preference in the database.

exists(connection=None)[source]

Return whether the object self really exists in the database specified by connection.

createsql(connection=None, term=True)[source]

Return SQL code to create this object.

dropsql(connection=None, term=True)[source]

Return SQL code to drop this object

classmethod names(connection, owner=None)[source]

Generator that yields the names of all preferences.

classmethod objects(connection, owner=None)[source]

Generator that yields all preferences.

class ll.orasql.JobClass(name, connection=None)[source]

Bases: ll.orasql.SchemaObject

Models a job class (from the dbms_scheduler package) in the database.

exists(connection=None)[source]

Return whether the object self really exists in the database specified by connection.

createsql(connection=None, term=True)[source]

Return SQL code to create this object.

dropsql(connection=None, term=True)[source]

Return SQL code to drop this object

fixname(code)[source]

Replace the name of the object in the SQL code code with the name of self.

classmethod names(connection)[source]

Generator that yields the names of all job classes.

classmethod objects(connection)[source]

Generator that yields all job classes.

references(connection=None)[source]

Objects directly used by self.

If connection is not None it will be used as the database connection from which to fetch data. If connection is None the connection from which self has been extracted will be used. If there is not such connection, you’ll get an exception.

referencedby(connection=None)[source]

Objects using self.

For the meaning of connection see references().

class ll.orasql.Job(name, owner=None, connection=None)[source]

Bases: ll.orasql.OwnedSchemaObject

Models a job (from the dbms_scheduler package) in the database.

exists(connection=None)[source]

Return whether the object self really exists in the database specified by connection.

createsql(connection=None, term=True)[source]

Return SQL code to create this object.

dropsql(connection=None, term=True)[source]

Return SQL code to drop this object

fixname(code)[source]

Replace the name of the object in the SQL code code with the name of self.

classmethod names(connection, owner=None)[source]

Generator that yields the names of all jobs.

classmethod objects(connection, owner=None)[source]

Generator that yields all jobs.

references(connection=None)[source]

Objects directly used by self.

If connection is not None it will be used as the database connection from which to fetch data. If connection is None the connection from which self has been extracted will be used. If there is not such connection, you’ll get an exception.

referencedby(connection=None)[source]

Objects using self.

For the meaning of connection see references().

class ll.orasql.OracleURLConnection(context, connection, mode)[source]

Bases: ll.url.Connection

open(url, mode='rb', encoding='utf-8', errors='strict')[source]

Open url for reading or writing. open() returns a Resource object.

Which additional parameters are supported depends on the actual resource created. Some common parameters are:

modestring

A string indicating how the file is to be opened (just like the mode argument for the builtin open() (e.g. "rb" or "wb").

headersmapping

Additional headers to use for an HTTP request.

databyte string

Request body to use for an HTTP POST request.

pythonstring or None

Name of the Python interpreter to use on the remote side (used by ssh URLs)

niceint or None

Nice level for the remote python (used by ssh URLs)

isdir(url)[source]

Test whether the resource url is a directory.

isfile(url)[source]

Test whether the resource url is a file.

mimetype(url)[source]

Return the mimetype of the file url.

owner(url)[source]

Return the name of the owner of the file url.

exists(url)[source]

Test whether the file url exists.

cdate(url)[source]

Return the “metadate change” date of the file/resource url as a datetime.datetime object in UTC.

mdate(url)[source]

Return the last modification date of the file/resource url as a datetime.datetime object in UTC.

walk(url, beforedir=True, afterdir=False, file=True, enterdir=True)[source]

Return an iterator for traversing the directory hierarchy rooted at the directory url.

Each item produced by the iterator is a Cursor object. It contains information about the state of the traversal and can be used to influence which parts of the directory hierarchy are traversed and in which order.

The arguments beforedir, afterdir, file and enterdir specify how the directory hierarchy should be traversed. For more information see the Cursor class.

Note that the Cursor object is reused by walk(), so you can’t rely on any attributes remaining the same across calls to next().

The following example shows how to traverse the current directory, print all files except those in certain directories:

from ll import url

for cursor in url.here().walk(beforedir=True, afterdir=False, file=True):
        if cursor.isdir:
                if cursor.url.path[-2] in (".git", "build", "dist", "__pycache__"):
                        cursor.enterdir = False
        else:
                print(cursor.url)
class ll.orasql.OracleFileResource(connection, url, mode='r', encoding='utf-8', errors='strict')[source]

Bases: ll.url.Resource

An OracleFileResource wraps an Oracle database object (like a table, view, function, procedure etc.) in a file-like API for use with ll.url.

class ll.orasql.OracleSchemeDefinition(scheme, usehierarchy, useserver, usefrag, islocal=False, isremote=False, defaultport=None)[source]

Bases: ll.url.SchemeDefinition

closeall(context)[source]

Close all connections active for this scheme in the context context.