I recently was in development prior to the problem that there is no way to convert an SQL table in a Laravel seeder, I have summarily decided to write a little script.
Particularly in the case of a larger table such as the countries, it is very troublesome to write the seeder manually. Here is the help:
https://laravel.stonelab.ch/sql-seeder-converter/
Have fun! 😉
28 Comments
You can post comments in this post.
Just knew about this tool from SO .. really helpfull 😀
Thanks a lot
Ferri Sutanto 8 years ago
Glad to hear that it helped! 🙂
I know there are still some issues, i will improve it as soon i have time.
Simon Funk 8 years ago
It would be great if it could also generate plain migrations, sometimes refactoring legacy php+mysql apps is a PITA
Andrea Bergamasco 8 years ago
Good hint, i will try to add it soon, thanks.
Simon Funk 7 years ago
I drop a simple mysql dump into the sql of your page:
CREATE TABLE IF NOT EXISTS `nerds` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`nerd_level` int(11) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT ‘0000-00-00 00:00:00’,
`updated_at` timestamp NOT NULL DEFAULT ‘0000-00-00 00:00:00’,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=6 ;
—
— Dumping data for table `nerds`
—
INSERT INTO `nerds` (`id`, `name`, `email`, `nerd_level`, `created_at`, `updated_at`) VALUES
(2, ‘stu pidaso’, ‘qrs881@glovoa.com’, 3, ‘2014-07-25 03:20:18’, ‘2014-07-29 03:05:35’),
(3, ‘jon doe’, ‘jon@doe.com’, 1, ‘2014-07-25 03:20:50’, ‘2014-07-25 03:20:50’),
(4, ‘bub’, ‘bub@glovoa.org’, 1, ‘2014-07-25 06:13:35’, ‘2014-07-25 09:32:53’),
(5, ‘joanne’, ‘chulasb@glovoa.org’, 1, ‘2014-07-25 06:16:03’, ‘2014-07-25 06:16:03’);
it goes into infinite converting mode. What do i need to do?
stu pida 7 years ago
We moved the server, due that it didn’t worked right. I’ve fixed it.
Simon Funk 7 years ago
don’t work
http://screencast.com/t/pNlQzjoC
Vladimir 7 years ago
I tried my table but it didn’t work.
It went into infinite loop.
here is my data:
INSERT INTO `users` (`id`, `name`, `email`, `sex`, `slug`, `avatar`, `created_at`, `updated_at`, `password`, `remember_token`) VALUES
(1, ‘Omar.Qusai’, ‘Omar.Qusai@me.me’, 1, ‘omarqusai’, ‘public/defaults/avatars/male.jpg’, ‘2017-04-11 08:34:07’, ‘2017-04-11 08:34:07’, ‘$2y$10$8XIg2SUULIVGX2HtRo0r3eMUr6UxLb0dUT7S.8Qf5HE2zlE7g2mPy’, NULL),
(2, ‘Muhammad Omar Abdu Allaah’, ‘MuhammadOmarAbduAllaah@me.me’, 1, ‘muhammad-omar-abdu-allaah’, ‘public/avatars/A5dKKNk8CT98jLtPwWc87Gqdqkr1aGvCiRGRbpxI.jpeg’, ‘2017-04-22 01:56:13’, ‘2017-04-22 02:02:46’, ‘$2y$10$UxgafPcKZZxb77BL7c6M..Y2FrMN/4QpgLkBu5tfR6Tw2.DgTrSz6’, ‘9XXnVpWBTszwerk81XzOomnsuGnYBgaODZLblWOABOZ5sr2jACk0zJUvJrBw’),
(3, ‘LarryFeefs’, ‘0dayscene@mail.ru’, 1, ‘larryfeefs’, ‘public/defaults/avatars/male.jpg’, ‘2017-04-22 06:22:47’, ‘2017-04-22 06:22:47’, ‘$2y$10$z/1tBYlARtbKlcskUZrlFumlAuxVHpUm6rNwn2dyEa.Dgq6D.nebC’, NULL),
(4, ‘فاطمة الزهراء نور الإسلام’, ‘fana1@me.me’, 0, ‘fatm-alzhra-nor-aleslam’, ‘public/defaults/avatars/female.jpg’, ‘2017-04-23 06:53:29’, ‘2017-04-23 06:53:29’, ‘$2y$10$W3BChMGlsjuALnwhYZVFj.K0SR/6ooUg3EnDqf7bFMwWt/iAhpn66’, ‘ml1r43nWuqfU9jx5Et1aEEyVWNhI81g3tX8HZTj7kt9qH4IljeGFJ42DIQMF’),
(5, ‘Muhammad Omar Abdu ArRahman’, ‘MOAA@me.me’, 1, ‘muhammad-omar-abdu-arrahman’, ‘public/defaults/avatars/male.jpg’, ‘2017-04-24 17:49:23’, ‘2017-04-24 17:49:23’, ‘$2y$10$XzfDC2gZZmTM9evnJCh7gOKu0dzW0KQHKYABugX61Jm/bQrZVh4L2’, NULL),
(6, ‘Person 1’, ‘person1@me.me’, 0, ‘person-1’, ‘public/defaults/avatars/female.jpg’, ‘2017-04-25 23:50:02’, ‘2017-04-25 23:50:02’, ‘$2y$10$XKJsm5BSOdbyXCJjUNzes.IeVolqyQV83ZPDqQOsMpNvWRV9vZJ5m’, NULL),
(7, ‘Person 2’, ‘person2@me.me’, 1, ‘person-2’, ‘public/defaults/avatars/male.jpg’, ‘2017-04-25 23:50:36’, ‘2017-04-25 23:50:36’, ‘$2y$10$SWksz8M3.a.764hJGeZ3POOjxeO52Lp8CkujEReeM/iJ3b.DUZXgW’, NULL),
(8, ‘basel’, ‘beso.qb94@gmail.com’, 1, ‘basel’, ‘public/defaults/avatars/male.jpg’, ‘2017-04-30 04:05:46’, ‘2017-04-30 04:05:46’, ‘$2y$10$1vSa3ze2QkILgBN8XFr3..a2kNBadT7r2f9Y6ZrvTRyjlYFqZMVju’, NULL);
Qussayyon Qamaron 6 years ago
fixed, it works now
Simon Funk 6 years ago
The First Letters proceeding underscores still depict a CamelCase in model names. I think it should be considered in the conversion of table name to ModelName.
besides that, this is *Awesome*!
James 6 years ago
Please add export button, to download it as text file.
Madvin 6 years ago
hello my friend! this is really helpful but can you help me? im trying to convert more than 1000 rows using this(sql-to-laravel-seeder) but it has errors
http://laravel.stonelab.ch/sql-seeder-converter/converter.php 500 (Internal Server Error)
thank you
nivra 6 years ago
Hi, could you send me the insert command?
Simon Funk 6 years ago
good day my friend here is the insert command. thank you my friend
https://pastebin.com/2utQ69eP
Nivra 6 years ago
I just edited your post to keep it cleaner 😉
It worked for me, probably a temporary issue. Here is the result:
https://pastebin.com/xN0fU5Hs
Simon Funk 6 years ago
thanks my friend i tested it and it worked, may i know the issue? what if i have another insert command with 1000+ rows will it work for me now using your website? thank you. 😀
Nivra 6 years ago
Great tool, but I am suggesting you to use updateOrCreate instead of create.
Zoran 5 years ago
your convert.php file not working
Miguel 4 years ago
fixed, thanks for the comment.
Simon Funk 4 years ago
Great tool.
today, it does not work. 19/12/2019
thanks
Adrian 4 years ago
Hello the converter not works.
Error 500 when send data to convert.
thanks
adrian 4 years ago
fixed, thanks for your comment.
Simon Funk 4 years ago
Thanks for your great tool
Adrian 4 years ago
Man you are a genious. Thank you very very mucho for this tool.
Luis Carlos Silva 4 years ago
Thanks, this is helpfull.
please html decode the output, cause if tables contains wysiwyg data it does not work as expected.
Ruud 3 years ago
Really Helpful bro thanks
Purushottam Tiwari 3 years ago
Wonderful tools! Thank you very much ♥
Tra Lee 3 years ago
really helpful thanks lot
anton 3 years ago
Post A Reply