Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » Attempting to save instance with null ID? [RSS Feed]

#1 Dec. 30, 2010 16:09:48

Jonathan H.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Attempting to save instance with null ID?


I'm migrating from SQLite to Oracle, and I'm getting an error thrown on the
line disn_requisition.save() claiming that it has a null ID. I have not
attempted to manually set or fiddle with id fields on any model, although I
do read them.
Any insight on what I need to do to address this?
IntegrityError at /upload/storage

ORA-01400: cannot insert NULL into ("INVDB"."INVDB_DISK_REQUISITION"."ID")

Request Method: POST Request URL:http://cmlnxbld01:8000/upload/storageDjango
Version: 1.2.3 Exception Type: IntegrityError Exception Value:

ORA-01400: cannot insert NULL into ("INVDB"."INVDB_DISK_REQUISITION"."ID")

Exception Location:
/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/django/db/backends/oracle/base.py
in execute, line 507 Python Executable:
/tools/python/2.7/Linux_x86_64/bin/python Python Version: 2.7.0 Python
Path:
Server
time: Thu, 30 Dec 2010 10:04:24 -0600
--
<http://jonathanscorner.com/>
Christos Jonathan Hayward, an Orthodox Christian author.

Author Bio <http://jonathanscorner.com/author/> • Books<http://cjshayward.com/>
• *Email <christos.jonathan.hayw...@gmail.com>* •
Facebook<http://www.facebook.com/christos.jonathan.hayward>
• LinkedIn <http://www.linkedin.com/in/jonathanhayward> •
Twitter<http://twitter.com/JonathansCorner>
• *Web <http://jonathanscorner.com/>* • What's
New?<http://jonathanscorner.com/>
I invite you to visit my "theology, literature, and other creative works"
site.

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 Dec. 30, 2010 19:26:25

W. C.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Attempting to save instance with null ID?


Jonathan ...

The problem is in the difference in SQLite and Oracle. Unlike MySQL,
PostgresQL, and SQLIte, Oracle doesn't have auto-generated primary keys. To
make up for that, Django on Oracle uses a trigger for each Django-managed
table that recognizes a NULL primary key on insert, and generates a key by
using a dedicated sequence for that table. Usually if you're creating the
tables from scratch, the Django management tools (syncdb, sqlall, etc) will
create the sequence and trigger for you. Without knowing more about how
your populated your schema, it's hard to say what went wrong, but if you run
'python manage.py sqlall invdb' it should print out the DDL to create the
trigger and sequence, and you can manually add them.

- Craig -

On Thu, Dec 30, 2010 at 11:09, Jonathan Hayward <
christos.jonathan.hayw...@gmail.com> wrote:

> I'm migrating from SQLite to Oracle, and I'm getting an error thrown on the
> line disn_requisition.save() claiming that it has a null ID. I have not
> attempted to manually set or fiddle with id fields on any model, although I
> do read them.
> Any insight on what I need to do to address this?
> IntegrityError at /upload/storage
>
> ORA-01400: cannot insert NULL into ("INVDB"."INVDB_DISK_REQUISITION"."ID")
>
> Request Method: POST Request URL:http://cmlnxbld01:8000/upload/storage> Django
> Version: 1.2.3 Exception Type: IntegrityError Exception Value:
>
> ORA-01400: cannot insert NULL into ("INVDB"."INVDB_DISK_REQUISITION"."ID")
>
> Exception Location:
> /tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/django/db/backends/oracle/base.py
> in execute, line 507 Python Executable:
> /tools/python/2.7/Linux_x86_64/bin/python Python Version: 2.7.0 Python
> Path:
> Server
> time: Thu, 30 Dec 2010 10:04:24 -0600
> --
> <http://jonathanscorner.com/>
> Christos Jonathan Hayward, an Orthodox Christian author.
>
> Author Bio <http://jonathanscorner.com/author/> •
> Books<http://cjshayward.com/>
> • *Email <christos.jonathan.hayw...@gmail.com>* •
> Facebook<http://www.facebook.com/christos.jonathan.hayward>
> • LinkedIn <http://www.linkedin.com/in/jonathanhayward> •
> Twitter<http://twitter.com/JonathansCorner>
> • *Web <http://jonathanscorner.com/>* • What's
> New?<http://jonathanscorner.com/>
> I invite you to visit my "theology, literature, and other creative works"
> site.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
>http://groups.google.com/group/django-users?hl=en.
>

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

  • Root
  • » Django
  • » Attempting to save instance with null ID? [RSS Feed]

Board footer

Moderator control

Enjoy the 17th of August
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support