fork download
  1. import sqlite3
  2.  
  3. def select(self, attr="*", table="reuters", fetch=None, tologfile=False, logfile=""):
  4. if fetch is None:
  5. fetch=self.fetchone
  6.  
  7. if tologfile:
  8. logfile = open(logfile, 'w')
  9. logfile.write(str(self.execute("select * from ?;".replace('?',table).replace("select * ", ("select "+attr))).fetch()))
  10. logfile.close()
  11. else: return str(self.execute("select * from ?;".replace('?',table).replace("select * ", ("select "+attr))).fetch())
  12.  
  13. if __name__ == '__main__':
  14. connection = sqlite3.connect('winkwinknudgenudgesaynomore.db')
  15. cursor = connection.cursor()
  16. cursor.execute("drop table reuters;")
  17. cursor.execute("create table reuters (foo text, bar text);")
  18. connection.commit()
  19. print select(cursor)
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty