【问题标题】:django migrating from sqlite3 to oracle causes ora-2000 errordjango 从 sqlite3 迁移到 oracle 导致 ora-2000 错误
【发布时间】: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,这种情况应该怎么办?

标签: python django oracle


【解决方案1】:

我在我的 12.2.0.1 数据库上尝试了您的 CREATE TABLE 语句,它成功了。另见this question。可能是您使用明确支持您的 Oracle DB 版本的 cx_oracle 版本,或者您将数据库升级到 Oracle 12。

【讨论】:

    猜你喜欢
    • 2017-02-14
    • 1970-01-01
    • 2021-08-10
    • 2019-01-09
    • 1970-01-01
    • 2019-09-08
    • 2014-03-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多