Django django_admin_log' doesn't exist - mysql

I have setup a new database with MySQL and run
python manage.py migrate
then run
python loaddata db.json
to load data from my previous sqlite database.
But now when I try to access the admin pages I get
ProgrammingError at /admin/
(1146, "Table 'myapp.django_admin_log' doesn't exist")
Other answers say to run syncdb but it not longer exists.
Any ideas?

Add django.contrib.admin in your INSTALLED_APPS, then run python manage.py migrate admin to create initial db tables for admin application. It will create django_admin_log table for you.

Related

Symfony - App uses wrong database name, CLI uses the correct one

hoping to get help with possibly a silly problem. I can't get Symfony to connect to the correct database.
My config line in .env is as follows
DATABASE_URL="mysql://root:root#127.0.0.1:3306/main?serverVersion=mariadb-10.4.27"
Creating a database using CLI works just fine and the database named "main" is created
bin/console doctrine:database:create
Created database `main` for connection named default
Running migration works OK and a table is created in the database
bin/console doctrine:migrations:migrate
WARNING! You are about to execute a migration in database "main" that could result in schema changes and data loss. Are you sure you wish to continue? (yes/no) [yes]:
> yes
[notice] Migrating up to DoctrineMigrations\Version20230117183120
[notice] finished in 28.6ms, used 22M memory, 2 migrations executed, 3 sql queries
Yet, when I try to access the site from the browser I get the following error
An exception occurred in the driver: SQLSTATE[HY000] [1049] Unknown database 'root'
Clearing the cache doesn't seem to help, I don't see any reference in the code to a database named root. Any clues on how to make Symfony to connect to the "main" database?
Cheers
P.

Getting error after changed sqlite to mysql, table doesn't exist?

i've finished developing a django project and wanted to change sqlite3 to MySql for a better database option. I tried in an empty project to change database, it worked like a charm. But now i changed db of my project and when i try to do python manage.py makemigrations it returns;
django.db.utils.ProgrammingError: (1146, "Table 'tvekstra-django-tracker.tvchannels_channels' doesn't exist")
Any help is appreciated, thanks.
I guess you have code that is trying to query the database before makemigrations runs. Here is a similar question. To help with your specific problem, you need to show the full traceback which will show where the query is occuring, and your views.py.

AWS Django Elastic Beanstalk migration error

Background
I created a website using Django and have it deployed on AWS EB with a MySQL Amazon RDS database. Recently I added a new field to one of the existing models in my models.py file. Everything worked fine on my local server (uses local SQLite, not RDS), but when I deployed the new update to EB I get the following error when I visit any page:
OperationalError at /
(1054, "Unknown column 'old_model.new_field' in 'field list'")
Question
What did I do wrong to get the error above and what can I do to fix it?
db-migrate.config:
container_commands:
01_migrate:
command: "django-admin.py migrate"
leader_only: true
option_settings:
aws:elasticbeanstalk:application:environment:
DJANGO_SETTINGS_MODULE: app.settings
Creating a manual migration with python manage.py makemigrations, if this doesn't found any new changes in models try the same with your app name and then migrate the DB with python manage.py migrate
This should solve your issue. if this doesn't solve your issue, clear all the migrations file the again run makemigrations
I suspect migrations are not running properly.
Create an EC2 instance and try to run migrations on it connected to RDS instead of local sqlite DB.
Make sure your EC2 instance and RDS are on the same VPC.
After that deploy your app to EB.

ERROR :Could not load the script in /usr/local/lib64/kamailio//kamctl/kamdbctl.mysql for database engine MYSQL

I am getting this error when trying to create the database on kamailio.
I've used the following command : sudo /usr/local/sbin/kamdbctl create.
I've set the DBENGINE=MYSQL in kamctlrc file and saved as well. Still getting this error. Anyone please suggest me how to proceed. I've tried all possible ways but couldn't find the solution anywhere online.
ERROR :Could not load the script in /usr/local/lib64/kamailio//kamctl/kamdbctl.mysql for database engine MYSQL
ERROR: database engine not loaded - tried 'MYSQL'
The file kamdbctl.mysql is installed when you install db_mysql module. Be sure that module is installed. Next is a sequence to get the module installed:
make include_modules="db_mysql" cfg
make all
make install

MySQL Test DB Failing

I set up a Django 2 app (and Python 3.6) with a remote MySQL DB (using mysqlclient), with proper permissions.
When I run my unit test, I get the following error: django.db.utils.ProgrammingError: (1146, “Table ‘test_<db>.<db>’ doesn’t exist”).
When I manually open the website at localhost, everything works fine.
Technically I could create a local dev DB for testing, but I would prefer that the test DB is created automatically.
EDIT
It seems like the issue was related to my tables not being managed by Django, see here.
I believe this is a duplicate.
Django : Table doesn't exist
If the table is missing, make sure you've got the right migration file (python manage.py makemigrations) and that you've applied it (python manage.py migrate).
What worked for me:
Changing my tables to managed = True.
Deleting migration files (except __init__.py).
python manage.py makemigrations
python manage.py migrate
And now my unit tests are running.