Generating Dummy Data Error- Django Series -Part -1

In Django series part 1 - Generating dummy data, I’m getting an error in datagrip(Refer to the image). I downloaded the database from mockaroo as instructed in the video, but when I run the MySQL database, it reports errors.

Although there are no email, phone, or membership fields in the database, it generates errors after running in the storefront schema.

Can anyone please help me?

Did you make sure to set up the Mockeroo fields like mosh did like before downloading? Like adding membership field and changing gender to phone etc.

Because your SQL insert statements there are only inserting id, first_name and last_name into your table, not the other fields like email, phone, membership etc

Thank you for responding. I’m a newbie who has only recently begun the Django series.

I followed the video and made the setup in the Mockeroo fields the same as mosh. It returned an error of “[1265] Data truncated for column ‘phone’ at row 1”. Please let me know where I’m going wrong.

Hi I had this error too, the error is because the dummy data is too large to fit inside the defined length for that column, its likely because some settings has changed with the software since the time of the video or something.

The best thing is just to continue on with the course because this sections ends just here then Mosh makes sure that we are on the same page on the ‘Resetting the Database’ lecture, he tells you to drag and drop a sql file into datagrip and some django files into vscode, so then everyone has the same data and can continue with the course

1 Like

Thanks for clearing up my doubt. I will move on with the course.

I continued with the course and after resetting the data and after uploading the seed file in datagrip it show me an error again - "Duplicate Entry ‘2’ for key ‘sstore_collection.PRIMARY’. Please help me.

This error means that there is already data in the table you are trying to update, be sure to make sure the database is fresh and clean from any other data before dropping in the files

I am sure the database is fresh but I don’t know why this error shows up every time. I tried in different ways but it didn’t work.

try deleting the storefront database and recreating from scratch as Mosh does in the “resetting the database” video

After watching the resetting database I tried it twice but the same error pops up. Even I tried deleting the localhost but the same error.

Can you write out step-by-step how you’re resetting the database?

  1. Dragged and dropped storefront folder from resources in VS code
  2. Changed password in → Database
  3. Run pipenv install in cmd
  4. Deleted database storefront in datagrip
  5. Created New database storefront in localhost
  6. Activated virtual environment - pipenv shell
  7. Run python migrate
  8. Refreshed data in datagrip
  9. Closed all sessions
  10. Dragged and dropped seed.sql file from data in resources
  11. Selected schema - storefront. Selected all and executed them all.

Then it shows me an error of Data truncation: Data too long for column ‘title’ at row 3

Hmm, well it looks like you’re doing everything correctly…I went back and watched the lesson over again and made notes:

  1. Go to zip file that Mosh gave us at the beginning of the course, called Resources.

  2. Navigate to Code/5- Django ORM/Start/storefront

  3. Drag and drop the storefront folder into VS Code. You could also save that folder where you prefer and open it in VS Code.

  4. In storefront/ , change the DATABASES “PASSWORD” from ‘MyPassword’ to your SQL password.

  5. Open a terminal window in VS Code and run ‘pipenv install’.

  6. Open DataGrip or whatever you’re using.

  7. Delete the storefront database by right clicking on it and going down to Drop. Click on it, and click delete on the popup window.

  8. Right click on ‘@localhost’ and open a new query console.

  9. Type into the query console ‘CREATE DATABASE storefront’.

  10. Verify that a new database was created in the dropdown list. It should be empty and have no subfolders.

  11. Back in VS Code, in the terminal run ‘pipenv shell’ to activate the virtual environment.

  12. Then, in the terminal, run ‘ python migrate’. You should see “Applying to store…” many times.

  13. Back in DataGrip, hit refresh, and all of the storefront tables should have been created. They are still empty of data.

  14. Before continuing, close all sessions of DataGrip. Go to the bottom of DataGrip and on the Services tab, right click on @localhost and “Close All Sessions”.

  15. Right click on storefront and open a new query console.

  16. From the Resources folder that Mosh gave us, navigate to Data/seed.sql. Drag and drop that seed.sql file into the new query console you created in DataGrip. You should see a giant list fill the query console.

  17. On the top select schema, and choose storefront. For me, DataGrip doesn’t always choose @localhost by default, so I sometimes have to select it from the dropdown menu to the right of schema.

  18. So now select all the data in the query console (Ctrl + a or Cmd + a).

  19. Execute it all with the green play triangle (or Ctrl + Shift + Return).

  20. Hopefully at this point your tables populate!

Perhaps the Resources folder that you downloaded from Mosh was corrupted in some way, so the seed.sql file is bad. Maybe delete it and re-download, and give it another run?