Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. def get_link():
  2.     cursor = connection.cursor()
  3.     cursor.execute("SELECT * FROM `websites_queue`")
  4.     records = cursor.fetchone()
  5.     cursor.close
  6.     if records is None:
  7.         sys.exit(0)
  8.     cursor = connection.cursor()
  9.     cursor.execute("SELECT `link` FROM `websites_queue` ORDER BY RAND() LIMIT 1")
  10.     records = cursor.fetchall()
  11.     global new_link
  12.     for record in records:
  13.         new_link = record[0]
  14.     cursor.close
  15.     cursor = connection.cursor()
  16.     cursor.execute("DELETE FROM `websites_queue` WHERE `link` = :link", (new_link))
  17.     connection.commit()
  18.     cursor.close
  19.     return new_link
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement