I am a university student, and I decided to use Django for my final year project. This means I am limited to using the University's MySQL database server. On the server, I am only allowed to have one database under my name and do not have permission to create any more of my own. I cannot use Django's test database functionality, as I only have one available and cannot create another. So, when I run ./manage.py test, I get the error...
Found 3 test(s).
Creating test database for alias 'default'...
Got an error creating the test database: (1044, "Access denied for user 'comp24394'@'%' to database 'test_comp24394'")
How can I get around this? Is it possible for "test" tables to be created in the main database? Or, can I have the test database on another server from the main - if so, what would be the steps to implement this?
Thank you for any help!
Edit: I have already configured my settings to be connected to my school's database server - The issue is that my user does not have permission to create a new database. I am limited to working with my one database, which is my production database. My question is it possible at all to use the production database to store test data and maybe get it function in a way that the test data is created in a table (say, "test_student"), and then that table is dropped after the test suite is done running? Or, do I have to configure a new setting where I can run my test database? I have to use my school's database server for the production database.
1 Answer 1
It is not a good practice to run your tests on a production database because it might lead to data corruption, impact on the performance of the server and have other unintended consequences.
Django Tests that require a database creates separate, blank databases for the tests and are not intended to be run on the production database.
Your best option, as has been suggested in the comments is to spin up a MySQL server on your local machine.
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;where Uid is the USER in this case. Django settings will at the end of the day become used for these connection string settings.