【发布时间】:2018-07-20 15:39:47
【问题描述】:
我在 windows server 2012 上有一个 Django 应用程序,它设置为 sqlite3 作为数据库,但它要投入生产,所以我将表迁移到服务器上的 oracle 11g,我不关心数据只是表格,所以当我运行时
python manage.py migrate
我收到 ORA-2000 错误:缺少 ALWAYS 关键字
我是 django 和一般网站的新手,我缺少什么?
数据库设置:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.oracle',
'NAME': 'orcl',
'USER': 'hr',
'PASSWORD': 'hr',
'HOST': 'localhost',
'PORT': '1521',
},
'OPTIONS': {
'timeout': 20,
'threaded': True,
}}
型号:
class ForecastSummary(models.Model):
party=models.ForeignKey(PartyDetailsFinal,on_delete=models.CASCADE,null=True)
annual_price = models.DecimalField(max_digits=100, decimal_places=5, default=Decimal('0.00000'), blank=True,
null=True)
annual_HW = models.DecimalField(max_digits=100, decimal_places=5, default=Decimal('0.00000'), blank=True,
null=True)
annual_SW = models.DecimalField(max_digits=100, decimal_places=5, default=Decimal('0.00000'), blank=True,
null=True)
annual_total = models.DecimalField(max_digits=100, decimal_places=5, default=Decimal('0.00000'), blank=True,
null=True)
back_maintenance = models.DecimalField(max_digits=100, decimal_places=5, default=Decimal('0.00000'),
blank=True )
forecast_year0 = models.DecimalField(max_digits=100, decimal_places=5, default=Decimal('0.00000'), blank=True,
null=True)
forecast_year1 = models.DecimalField(max_digits=100, decimal_places=5, default=Decimal('0.00000'), blank=True,
null=True)
forecast_year2 = models.DecimalField(max_digits=100, decimal_places=5, default=Decimal('0.00000'), blank=True,
null=True)
forecast_year3 = models.DecimalField(max_digits=100, decimal_places=5, default=Decimal('0.00000'), blank=True,
null=True)
forecast_year4 = models.DecimalField(max_digits=100, decimal_places=5, default=Decimal('0.00000'), blank=True,
null=True)
forecast_year5 = models.DecimalField(max_digits=100, decimal_places=5, default=Decimal('0.00000'), blank=True,
null=True)
forecast_total_0to3_years = models.DecimalField(max_digits=100, decimal_places=5, default=Decimal('0.00000'),
blank=True )
forecast_total_0to5_years = models.DecimalField(max_digits=100, decimal_places=5, default=Decimal('0.00000'),
blank=True )
def __str__(self):
return "Instance Number =" + str(self.party.item_instance_number)
【问题讨论】:
-
假设你改变了settings.py上的数据库,你能生成sql输出吗?
python manage.py sql -
说未知命令'sql'
-
对不起,
sqlmigrate我的意思是 -
您确定服务器是 12c,而不仅仅是您的客户端? select * from product_component_version 或 select * from v$version 报告是什么?另外,哪个版本的 Django 和 cx_Oracle(和 Python)。
-
服务器是11g,客户端是12c,这种情况应该怎么办?