def delete(conn, table, where=None, returning=None): try: return conn.delete(table, where=where, returning=returning) except psycopg2.Error, e: conn.rollback() raise DatabaseError("%s:%s" % (e.pgcode, e.pgerror))
def get_conn(db_config=None): global db_initialized if not db_initialized: if db_config: init_db_pool(db_config) else: raise DatabaseError("Database haven't! been initialized") return pypgwrap.connection()
def join_dict(conn, tables, key, where=None, on=None, order=None, columns=None, limit=None, offset=None): try: return conn.join_dict(tables, key, where=where, on=on, order=order, columns=columns, limit=limit, offset=offset) except psycopg2.Error, e: conn.rollback() raise DatabaseError("%s:%s" % (e.pgcode, e.pgerror))
def select_dict(conn, table_name, key, **kwargs): try: return conn.select_dict(table_name, key, **kwargs) except psycopg2.Error, e: conn.rollback() raise DatabaseError("%s:%s" % (e.pgcode, e.pgerror))
def query(conn, sql, params=None): try: return conn.query(sql, params) except psycopg2.Error, e: conn.rollback() raise DatabaseError("%s:%s" % (e.pgcode, e.pgerror))