=======
connect
=======

.. py:method:: connect(self) 

**domain**: server

**language**: python

**class** :doc:`Task class </refs/server/task_api>`

Description
===========

Use ``connect`` to procure a connection from the SQLAlchemy connection pool.

The return value of this method is a DBAPI connection.

A developer must return a connection to the connection poll when it is no 
longer needed by calling ``close`` method of the connection.

Example
=======

.. code-block:: py

  def delete_rec(item, item_id):
    conection = item.task.connect()
    try:
      cursor = conection.cursor()
      cursor.execute('delete from %s where id=%s' % (item.table_name, item_id))
      conection.commit()
    finally:
      conection.close()

