Advertisement
Guest User

Untitled

a guest
Mar 13th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. select
  2. *,
  3. (select count(*) from domains) as count,
  4. (select 456976-count(*) from domains) as remaining
  5. from domains
  6. order by domain desc
  7. limit 0, 1;
  8.  
  9. use mydatabase
  10. DELIMITER $$
  11. DROP PROCEDURE IF EXISTS `MyDataStatus` $$
  12. CREATE PROCEDURE `MyDataStatus` ()
  13. BEGIN
  14. SET @SecondsToPause = 10;
  15. SELECT COUNT(*) INTO @CurrentCount FROM domains;
  16. SET @Remaining = 456976 - @CurrentCount;
  17. WHILE @Remaining > 0 DO
  18. SELECT *,@CurrentCount as `count`,@CurrentCount as `remaining`
  19. FROM domains ORDER BY domain DESC LIMIT 0, 1;
  20. SELECT SLEEP(@SecondsToPause) INTO @SleepValue;
  21. SELECT COUNT(*) INTO @CurrentCount FROM domains;
  22. SET @Remaining = 456976 - @CurrentCount;
  23. END $$
  24. DELIMITER ;
  25.  
  26. set MYSQL_USER=root
  27. set MYSQL_PASS=password
  28. set MYSQL_MYDB=mydatabase
  29. set MYSQL_CONN=-u%MYSQL_USER% -p%MYSQL_PASS% -D%MYSQL_MYDB%
  30. mysql %MYSQL_CONN% -ANe"CALL MyDataStatus()"
  31.  
  32. mysql %MYSQL_CONN%
  33.  
  34. mysql> CALL MyDataStatus();
  35.  
  36. watch -n 10 'mysql --database=dbname --user=username --password=$(cat /path/to/file/with/mysql/password) --execute="select *, (select count(*) from domains) as count, (select 456976-count(*) from domains) as remaining from domains order by domain desc limit 0, 1;"'
  37.  
  38. while true; do mysql -u root -p[password] -e "select * from table"; sleep 5; clear; done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement