Advertisement
Guest User

Untitled

a guest
Sep 28th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. def __init__(self,readLink):
  2. if readLink==0:
  3. self.linksToRead = 1000000000
  4. else:
  5. self.linksToRead = readLink
  6. self.linkCount = 0
  7. self.wordsList =[]
  8. self.parsedLinks=[]
  9. self.urlList =[]
  10. self.connection = pymysql.connect(host='localhost',
  11. user='root',
  12. password='s3cr3tp@ssw0rd',
  13. db='scrapper',
  14. charset='utf8',
  15. cursorclass=pymysql.cursors.DictCursor, autocommit=True)
  16.  
  17.  
  18. with self.connection.cursor() as cursor:
  19.  
  20. sql2 = "SELECT * FROM `linksparsed`"
  21. try:
  22. cursor.execute(sql2)
  23. #self.connection.commit()
  24. except Exception as ex:
  25. print(ex)
  26.  
  27. result = cursor.fetchall()
  28. cursor.rowcount #shows 3
  29. totalLength = len(result) # shows 0
  30. for row in result:
  31. self.parsedLinks.append(row)
  32.  
  33. def fetchall(self):
  34. """Fetch all the rows"""
  35. self._check_executed()
  36. if self._rows is None:
  37. return ()
  38. if self.rownumber:
  39. result = self._rows[self.rownumber:] <<-------
  40. else:
  41. result = self._rows
  42. self.rownumber = len(self._rows)
  43. return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement