Skip to content

Instantly share code, notes, and snippets.

@lukeasrodgers
Created September 12, 2016 22:09
Show Gist options
  • Save lukeasrodgers/8bbd67801273628c517d53c57b5f7574 to your computer and use it in GitHub Desktop.
Save lukeasrodgers/8bbd67801273628c517d53c57b5f7574 to your computer and use it in GitHub Desktop.
some misc procedures for creating test/dummy data in mysql
/* quickly/hackily create randomish string data with md5 */
DELIMITER $$
DROP PROCEDURE IF EXISTS user_promos;
CREATE PROCEDURE user_promos()
BEGIN
DECLARE i INT DEFAULT 1;
WHILE i < 5000 DO
INSERT INTO promotions2 (opener_id, message, url, created_at, updated_at, ptype, client) VALUES (127527, md5(i + "foo"), concat("https://", md5(i), ".com/", md5(i-1)), now(), now(), "sf", "web");
SET i = i + 1;
END WHILE;
END$$
DELIMITER ;
/* randomly flip between 1 and 2 for integer values */
DELIMITER $$
DROP PROCEDURE IF EXISTS promo_nets;
CREATE PROCEDURE promo_nets()
BEGIN
DECLARE i INT DEFAULT 300;
WHILE i < 1609106 DO
INSERT INTO promotion_networks (promotion_id, network_id) VALUES (i, ceil(rand() * 2));
SET i = i + 1;
END WHILE;
END$$
DELIMITER ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment