def insert_data(test_case, host, port):
 d = get_postgres_connection(host, port)
 def create_database(connection):
  connection.autocommit = True
  cursor = connection.cursor()
  cursor.execute('CREATE DATABASE flockertest;')
  cursor.close()
  connection.close()
 d.addCallback(create_database)
 d.addCallback((lambda _: get_postgres_connection(host, port, u'flockertest')))
 def add_data(connection):
  cursor = connection.cursor()
  cursor.execute('CREATE TABLE testtable (testcolumn int);')
  cursor.execute('INSERT INTO testtable (testcolumn) VALUES (123);')
  connection.commit()
  connection.close()
 d.addCallback(add_data)
 return d

def insert_data ( test_case , host , port ) : d = get_postgres_connection ( host , port ) def create_database ( connection ) : connection . autocommit = True cursor = connection . cursor ( ) cursor . execute ( 'CREATE DATABASE flockertest;' ) cursor . close ( ) connection . close ( ) d . addCallback ( create_database ) d . addCallback ( ( lambda _ : get_postgres_connection ( host , port , u'flockertest' ) ) ) def add_data ( connection ) : cursor = connection . cursor ( ) cursor . execute ( 'CREATE TABLE testtable (testcolumn int);' ) cursor . execute ( 'INSERT INTO testtable (testcolumn) VALUES (123);' ) connection . commit ( ) connection . close ( ) d . addCallback ( add_data ) return d
insert some data into the database .