Jam.py documentation

connect

connect(self)

domain: server

language: python

class Task class

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

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()