rajeevs1992

Write sentences to database

Dec 14th, 2011
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. def stop(l,owner):
  2.      cursor=MySQLdb.connect("localhost","root","password","exp").cursor()
  3.      query="CREATE TABLE data (tweet varchar(140),owner varchar(50))"
  4.      cursor.execute(query)
  5.      c=0
  6.      for i in l:
  7.          currentUser=owner[c]
  8.          c=c+1
  9.          for j in i:
  10.              text=MySQLdb.escape_string(j.text)
  11.              cursor.execute("""INSERT INTO data VALUES("%s","%s")"""%(text,currentUser))
  12.      print "done"
  13.  
  14.  
Advertisement
Add Comment
Please, Sign In to add comment