Reputation: 185
I have a Site that allows users to create a profile and have their own profile page, I want to generate a bunch of fake users to test my site, I have all the details stored into a MySQL Database and was wondering how I would add a random bunch of users to it without having to go to the registration form over and over again!
Here's a screenshot of my current database layout (Field Names)
Table Name is user
I have seen randomuser.me's API but since I am no good with JSON, I'd have no idea where to start on this! I have also seen generatedata.com but again, have no Idea how that works!
Upvotes: 0
Views: 1836
Reputation: 28206
You could use a procedure like this one:
CREATE PROCEDURE myfill()
BEGIN
DECLARE v1 INT DEFAULT 1000; -- number of users to be generated ..
DECLARE txt varchar(8);
SET txt=v1;
WHILE v1 > 0 DO
insert INTO user (user_email,user_password,user_firstname,
user_lastname,user_avatar,user_username,
user_backgroundpicture,user_joindate)
VALUES (concat('mail',txt,'@domain.com'), concat('pwd',txt),
concat('first',txt),concat('last',txt),concat('avatar',txt),
concat('user',txt),concat('bg',txt),now() );
SET v1 = v1 - 1;
SET txt=v1;
END WHILE;
END//
call myfill();
See demo here: http://sqlfiddle.com/#!9/adf23/1
Upvotes: 4