Top Description Fields Constructors Methods
com.ziclix.python.sql

public Class PyConnection

Additional top-level class in compilation unit: ConnectionFunc.

extends PyObject
implements ClassDictInit, ContextManager, Traverseproc
Class Inheritance
All Implemented Interfaces
org.python.core.Traverseproc, org.python.core.ContextManager, org.python.core.ClassDictInit
Imports
java.sql.Connection, .SQLException, java.util.Collections, .WeakHashMap, .Set, org.python.core.ClassDictInit, .ContextManager, .Py, .PyBuiltinMethodSet, .PyException, .PyInteger, .PyList, .PyObject, .PyString, .PyUnicode, .ThreadState, .Traverseproc, .Visitproc, com.ziclix.python.sql.util.PyArgParser

A connection to the database.
Author
brian zimmer

Field Summary

Modifier and TypeField and Description
protected static PyList
__members__

Field __members__

protected static PyList
__methods__

Field __methods__

protected boolean
closed

True if closed.

protected Connection
connection

The underlying java.sql.Connection.

private Set<PyCursor>
cursors

Underlying cursors.

private Set<PyStatement>
statements

Underlying statements.

protected boolean
supportsMultipleResultSets

Whether multiple ResultSets are supported.

protected boolean
supportsTransactions

Whether transactions are supported.

Inherited from org.python.core.PyObject:
attributesgcMonitorGlobalobjtypeTYPE

Constructor Summary

AccessConstructor and Description
public
PyConnection(Connection connection)

Create a PyConnection with the open connection.

Method Summary

Modifier and TypeMethod and Description
public PyObject
public PyObject
public boolean
public boolean
__exit__(PyObject type, PyObject value, PyObject traceback)

public PyObject

Returns:

the value for the attribute of the specified name
__findattr_ex__
(String
the name of the attribute of interest
name
)

Overrides org.python.core.PyObject.__findattr_ex__.

Finds the attribute.

public void
__setattr__(String name, PyObject value)

Overrides org.python.core.PyObject.__setattr__.

Sets the attribute.

pack-priv void
add(PyStatement
statement
statement
)

Method register

public static void
classDictInit(PyObject dict)

Method classDictInit

public void
close()

Close the connection now (rather than whenever __del__ is called).

public void
commit()

Commit any pending transaction to the database.

pack-priv boolean

Returns:

boolean
contains
(PyStatement
statement
statement
)

Method contains

public PyCursor

Returns:

a new cursor using this connection
cursor
()

Return a new Cursor Object using the connection.

public PyCursor

Returns:

a new cursor using this connection
cursor
(boolean
if true, dynamically iterate the result
dynamicFetch
)

Return a new Cursor Object using the connection.

public PyCursor

Returns:

a new cursor using this connection
cursor
(boolean
if true, dynamically iterate the result
dynamicFetch
,
PyObject
the type of the underlying ResultSet
rsType
,
PyObject
the concurrency of the underlying ResultSet
rsConcur
)

Return a new Cursor Object using the connection.

public PyObject

Returns:

the native form of this statement
nativesql
(PyObject nativeSQL)

Converts the given SQL statement into the system's native SQL grammar.

public boolean
pack-priv void
remove(PyCursor cursor)

Remove an open PyCursor.

public void
rollback()

This method is optional since not all databases provide transaction support.

public String

Returns:

string representation of the object.
toString
()

Overrides org.python.core.PyObject.toString.

Produces a string representation of the object.

public int
traverse(Visitproc visit, Object arg)

Implements org.python.core.Traverseproc.traverse.

Traverses all directly contained PyObjects.

Inherited from org.python.core.PyObject:
__abs____add____and____call____call____call____call____call____call____call____call____call____call____call____call____call____call____call____call____cmp____coerce____coerce_ex____complex____contains____delattr____delattr____delete____delitem____delitem____delslice____delslice____dir____div____divmod____ensure_finalizer____eq____findattr____findattr____finditem____finditem____finditem____float____floordiv____format____ge____get____getattr____getattr____getitem____getitem____getnewargs____getslice____getslice____gt____hash____hex____iadd____iand____idiv____idivmod____ifloordiv____ilshift____imod____imul____index____int____invert____ior____ipow____irshift____isub____iter____iternext____itruediv____ixor____le____len____long____lshift____lt____mod____mul____ne____neg____nonzero____not____oct____or____pos____pow____pow____radd____rand____rawdir____rdiv____rdivmod____reduce____reduce_ex____reduce_ex____repr____rfloordiv____rlshift____rmod____rmul____ror____rpow____rrshift____rshift____rsub____rtruediv____rxor____set____setattr____setitem____setitem____setitem____setslice____setslice____str____sub____tojava____truediv____trunc____unicode____xor___add_and_callextra_cmp_div_divmod_doget_doget_doset_eq_floordiv_ge_gt_iadd_iand_idiv_idivmod_ifloordiv_ilshift_imod_imul_in_ior_ipow_irshift_is_isnot_isub_itruediv_ixor_jcall_jcallexc_jthrow_le_lshift_lt_mod_mul_ne_notin_or_pow_rshift_sub_truediv_unsupportedop_xoradaptToCoerceTupleasDoubleasIndexasIndexasIntasIntasIterableasLongasLongasNameasNameasStringasStringasStringOrNullasStringOrNullbit_lengthconjugatedelDictdelTypedispatch__init__equalsfastGetClassfastGetDictfinalizegetDictgetJavaProxygetTypehashCodeimpAttrimplementsDescrDeleteimplementsDescrGetimplementsDescrSetinvokeinvokeinvokeinvokeinvokeinvokeisCallableisDataDescrisIndexisIntegerisMappingTypeisNumberTypeisSequenceTypemergeClassDictmergeDictAttrmergeListAttrnoAttributeErrorobject___subclasshook__readonlyAttributeErrorrunsupportedopMessagesetDictsetTypeunsupportedopMessage

Field Detail

__members__back to summary
protected static PyList __members__

Field __members__

__methods__back to summary
protected static PyList __methods__

Field __methods__

closedback to summary
protected boolean closed

True if closed.

connectionback to summary
protected Connection connection

The underlying java.sql.Connection.

cursorsback to summary
private Set<PyCursor> cursors

Underlying cursors.

statementsback to summary
private Set<PyStatement> statements

Underlying statements.

supportsMultipleResultSetsback to summary
protected boolean supportsMultipleResultSets

Whether multiple ResultSets are supported.

supportsTransactionsback to summary
protected boolean supportsTransactions

Whether transactions are supported.

Constructor Detail

PyConnectionback to summary
public PyConnection(Connection connection) throws SQLException

Create a PyConnection with the open connection.

Method Detail

__enter__back to summary
public PyObject __enter__(ThreadState ts)

Implements org.python.core.ContextManager.__enter__.

__enter__back to summary
public PyObject __enter__()
__exit__back to summary
public boolean __exit__(ThreadState ts, PyException exception)

Implements org.python.core.ContextManager.__exit__.

__exit__back to summary
public boolean __exit__(PyObject type, PyObject value, PyObject traceback)
__findattr_ex__back to summary
public PyObject __findattr_ex__(String name)

Overrides org.python.core.PyObject.__findattr_ex__.

Finds the attribute.

Parameters
name:String

the name of the attribute of interest

Returns:PyObject

the value for the attribute of the specified name

Annotations
@Override

__setattr__back to summary
public void __setattr__(String name, PyObject value)

Overrides org.python.core.PyObject.__setattr__.

Sets the attribute.

Annotations
@Override
addback to summary
pack-priv void add(PyStatement statement)

Method register

Parameters
statement:PyStatement

statement

classDictInitback to summary
public static void classDictInit(PyObject dict)

Method classDictInit

closeback to summary
public void close()

Close the connection now (rather than whenever __del__ is called). The connection will be unusable from this point forward; an Error (or subclass) exception will be raised if any operation is attempted with the connection. The same applies to all cursor objects trying to use the connection.

commitback to summary
public void commit()

Commit any pending transaction to the database. Note that if the database supports an auto-commit feature, this must be initially off. An interface method may be provided to turn it back on.

Database modules that do not support transactions should implement this method with void functionality.

containsback to summary
pack-priv boolean contains(PyStatement statement)

Method contains

Parameters
statement:PyStatement

statement

Returns:boolean

boolean

cursorback to summary
public PyCursor cursor()

Return a new Cursor Object using the connection. If the database does not provide a direct cursor concept, the module will have to emulate cursors using other means to the extent needed by this specification.

Returns:PyCursor

a new cursor using this connection

cursorback to summary
public PyCursor cursor(boolean dynamicFetch)

Return a new Cursor Object using the connection. If the database does not provide a direct cursor concept, the module will have to emulate cursors using other means to the extent needed by this specification.

Parameters
dynamicFetch:boolean

if true, dynamically iterate the result

Returns:PyCursor

a new cursor using this connection

cursorback to summary
public PyCursor cursor(boolean dynamicFetch, PyObject rsType, PyObject rsConcur)

Return a new Cursor Object using the connection. If the database does not provide a direct cursor concept, the module will have to emulate cursors using other means to the extent needed by this specification.

Parameters
dynamicFetch:boolean

if true, dynamically iterate the result

rsType:PyObject

the type of the underlying ResultSet

rsConcur:PyObject

the concurrency of the underlying ResultSet

Returns:PyCursor

a new cursor using this connection

nativesqlback to summary
public PyObject nativesql(PyObject nativeSQL)

Converts the given SQL statement into the system's native SQL grammar. A driver may convert the JDBC sql grammar into its system's native SQL grammar prior to sending it; this method returns the native form of the statement that the driver would have sent.

Returns:PyObject

the native form of this statement

refersDirectlyToback to summary
public boolean refersDirectlyTo(PyObject ob)

Implements org.python.core.Traverseproc.refersDirectlyTo.

Doc from org.python.core.Traverseproc.refersDirectlyTo.

Optional operation. Should only be implemented if it is more efficient than calling traverse(Visitproc, Object) with a visitproc that just watches out for ob. Must return false if ob is null.

Annotations
@Override
removeback to summary
pack-priv void remove(PyCursor cursor)

Remove an open PyCursor.

rollbackback to summary
public void rollback()

This method is optional since not all databases provide transaction support.

In case a database does provide transactions this method causes the database to roll back to the start of any pending transaction. Closing a connection without committing the changes first will cause an implicit rollback to be performed.

toStringback to summary
public String toString()

Overrides org.python.core.PyObject.toString.

Produces a string representation of the object.

Returns:String

string representation of the object.

Annotations
@Override

traverseback to summary
public int traverse(Visitproc visit, Object arg)

Implements org.python.core.Traverseproc.traverse.

Doc from org.python.core.Traverseproc.traverse.

Traverses all directly contained PyObjects. Like in CPython, arg must be passed unmodified to visit as its second parameter. If Visitproc#visit(PyObject, Object) returns nonzero, this return value must be returned immediately by traverse. Visitproc#visit(PyObject, Object) must not be called with a null PyObject-argument.

Annotations
@Override