无法从 Django sqlite3 迁移到 postgres,出现"psycopg2.errors.UndefinedTable: relation doest not exist"错误



我正试图将sqlite3 db从我的Django应用程序迁移到postgres db。我已经尝试了所有的教程在那里,但似乎不能解决这个错误,当我试图运行'python管理.py迁移——运行-syncdb'或'python管理.py迁移'。我已经安装了psycopg2。

settings.py

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'db',
'USER': 'postgres',
'PASSWORD': 'admin',
'HOST': 'localhost',
'PORT': '5432',
}
}

错误是"psycopg2.errors。UndefinedTable: relation "users_postcategory"不存在第一行:…category";name";users_postcategory";;name";从"users_pos…">

screenshot1

screenshot2

尝试添加public.

con = psycopg2.connect(
host = 'localhost',
user = 'postgres',
password = '2356216',
database = 'excursion'
)
cursor = con.cursor()
sql = ''
if lang == 'ru':
sql = f"""SELECT ID, Name_ru, Description_ru, Photo, Point_width, Point_longitude, Link
FROM memorable
JOIN communication ON public.communication.memorableid = public.memorable.id 
WHERE communication.RouteID = {ExcID}"""
if lang == 'en':
sql = f"""SELECT ID, Name, Description, Photo, Point_width, Point_longitude, Link 
FROM memorable 
JOIN communication ON communication.memorableid = memorable.id 
WHERE communication.RouteID = {ExcID}"""
cursor.execute(sql)
result = cursor.fetchall()
return result

相关内容

最新更新