old_contents: #!/usr/bin/python
  import psycopg2
  import re
  
  '''
  @author: anant bhardwaj
  @date: Oct 3, 2013
  
  DataHub internal APIs for postgres database
  '''
  host = 'localhost'
  port = 5432
  
  class PGBackend:
    def __init__(
        self, user, password, host=host, port=port, db_name=None):
  
      self.user = user
      self.password = password
      self.host = host
      self.port = port
  
      if db_name:
        self.connection = psycopg2.connect(
            user=user, password=password, host=host, port=port, database=db_name)
      else:
        self.connection = psycopg2.connect(
            user=user, password=password, host=host, port=port)
  
      self.connection.set_isolation_level(
          psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
  
    def execute_sql(self, query, params=None):
      result = {
          'status': False,
          'row_count': 0,
          'tuples': [],
          'fields': []
      }
  
      conn = self.connection 
      c = conn.cursor()
      c.execute(query.strip(), params)
  
      try:
        result['tuples'] = c.fetchall()
      except:
        pass
  
      result['status'] = True
      result['row_count'] = c.rowcount
      if c.description:
        result['fields'] = [{'name': col[0], 'type': col[1]} for col in c.description]
  
      tokens = query.strip().split(' ', 2)
      c.close()
      return result
  
    def close(self):    
      self.connection.close()
  
  
  
  def main():
    backend = PGBackend(user="postgres", password="postgres", host=host, port=port)
    backend.execute_sql("DROP TABLE IF EXISTS sqlpaxoslog;")
    backend.execute_sql("CREATE TABLE IF NOT EXISTS sqlpaxoslog (lastseqnum INT);")
    backend.execute_sql("UPDATE sqlpaxoslog SET lastseqnum=-1;")
  
  if __name__ == '__main__':
    main()
  
  
new_contents: #!/usr/bin/python
  import psycopg2
  import re
  
  '''
  @author: anant bhardwaj
  @date: Oct 3, 2013
  
  DataHub internal APIs for postgres database
  '''
  host = 'localhost'
  port = 5432
  
  class PGBackend:
    def __init__(
        self, user, password, host=host, port=port, db_name=None):
  
      self.user = user
      self.password = password
      self.host = host
      self.port = port
  
      if db_name:
        self.connection = psycopg2.connect(
            user=user, password=password, host=host, port=port, database=db_name)
      else:
        self.connection = psycopg2.connect(
            user=user, password=password, host=host, port=port)
  
      self.connection.set_isolation_level(
          psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
  
    def execute_sql(self, query, params=None):
      result = {
          'status': False,
          'row_count': 0,
          'tuples': [],
          'fields': []
      }
  
      conn = self.connection 
      c = conn.cursor()
      c.execute(query.strip(), params)
  
      try:
        result['tuples'] = c.fetchall()
      except:
        pass
  
      result['status'] = True
      result['row_count'] = c.rowcount
      if c.description:
        result['fields'] = [{'name': col[0], 'type': col[1]} for col in c.description]
  
      tokens = query.strip().split(' ', 2)
      c.close()
      return result
  
    def close(self):    
      self.connection.close()
  
  
  
  def main():
    backend = PGBackend(user="postgres", password="postgres", host=host, port=port)
    backend.execute_sql("DROP TABLE IF EXISTS sqlpaxoslog;")
    backend.execute_sql("CREATE TABLE IF NOT EXISTS sqlpaxoslog (lastseqnum INT);")
    backend.execute_sql("INSERT INTO sqlpaxoslog VALUES (-1);")
  
  if __name__ == '__main__':
    main()
  
  
subject: fix for insert