Skip to content

Column unknown tablename.RDB$DB_KEY #139

Open
@gribok

Description

@gribok

I have a legacy database table without a primary key.
Firebird is using RDB$DB_KEY as alternative internal primary key.

I tried to model it in Django.
But when I execute a SELECT statement, I receive following error message:
('Error while preparing SQL statement:\n- SQLCODE: -206\n- Dynamic SQL Error\n- SQL error code = -206\n- Column unknown\n- testtable.RDB$DB_KEY\n- At line 1, column 18', -206, 335544569)

I've tried it with Django 2.2, but got the same error message.

myappmodels.py

from django.db import models

# Create your models here.

class MyModel(models.Model):
    db_key = models.CharField(primary_key=True, db_column='rdb$db_key', max_length=10)
    test_field= models.CharField(max_length=15, blank=True, null=True)

    class Meta:
        managed = False
        db_table = 'testtable'

Version
Django: 3.2
django-firebird: 2.2.1
django-utils-six 2.0
fdb 2.0.2

$ python -V
Python 3.9.15

The SELECT statement with via fdb package works perfectly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions