inspectdb

Django keeps migrating the same foreign key

好久不见. 提交于 2021-01-28 02:00:41
问题 I am importing an existing database into it's own Django project. I have generated the initial models from the database, via inspectdb , and am enabling Django to control each table one at a time by commenting the managed=False lines in the table meta settings. I've started with the simple models and am hitting a snag when enabling tables with foreign keys. Django keeps generating the same migration for the foreign key DocTagID and I'm not sure why it is doing so ? The table in question is

Django: using more than one database with inspectdb?

房东的猫 提交于 2020-01-01 09:03:12
问题 My settings file's database section looks like this: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'C:/Users/Desktop/test.db' }, 'blah':{ 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'C:/Users/Desktop/test2.db' } } When I run the command python manage.py inspectdb > models.py , I only get the model generated for the default database, but not the second one. How could I get both models generated? 回答1: From the documentation: --database DATABASE Specifies the

Django inspectdb issue using Oracle database

戏子无情 提交于 2019-12-30 07:35:42
问题 Installed cx_oracle and ran inspectdb. Don't seem to get any output? Can somebody help? Is there a known issue using inspectdb with Oracle? Below is the command and settings.py. python manage.py inspectdb --database xxx_db # This is an auto-generated Django model module. # You'll have to do the following manually to clean this up: # * Rearrange models' order # * Make sure each model has one field with primary_key=True # Feel free to rename the models, but don't rename db_table values or field

ProgrammingError: 1064 while executing inspectdb with django and mysql database

时光总嘲笑我的痴心妄想 提交于 2019-12-11 04:29:19
问题 I have two databases configured in settings.py: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'postgres', 'USER': 'postgres', 'PASSWORD': 'password', 'HOST': '127.0.0.1', 'PORT': '5432', }, 'db2': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'database', 'USER': 'user', 'PASSWORD': 'password', 'HOST': 'ip address', 'PORT': 'port', } } The server which hosts db2 uses mysql 4.1.2. I am using Python 3.7.3 + django 2.2.5 + mysqlclient 1.4.4. When I run python

How do I inspectdb 1 table from database which Contains 1000 tables

本小妞迷上赌 提交于 2019-12-03 07:44:04
问题 I got a schema which Contains 1000 tables,and many of them I don't need, how can I just inspectdb the just tables that I need? 回答1: You can do it in the python console, or in *.py file: from django.core.management.commands.inspectdb import Command from django.conf import settings from your_project_dir.settings import DATABASES # replace `your_project_dir` settings.configure() settings.DATABASES = DATABASES Command().execute(table_name_filter=lambda table_name: table_name in ('table_what_you

Django inspectdb issue using Oracle database

▼魔方 西西 提交于 2019-12-01 01:55:26
Installed cx_oracle and ran inspectdb. Don't seem to get any output? Can somebody help? Is there a known issue using inspectdb with Oracle? Below is the command and settings.py. python manage.py inspectdb --database xxx_db # This is an auto-generated Django model module. # You'll have to do the following manually to clean this up: # * Rearrange models' order # * Make sure each model has one field with primary_key=True # Feel free to rename the models, but don't rename db_table values or field names. # # Also note: You'll have to insert the output of 'django-admin.py sqlcustom [appname]' # into