I forgot to mention that I am using django point release 0.91.

Nick

On 5/21/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Hey all,

I am just starting with django; I think it is really cool, a big break
from Java/Struts dev for me. Anyways, I am experimenting with a simple
blog app. So, on to some issues. Here is output:

bastion:~ nick$ python dev/django-projects/myblog/manage.py sql blog
BEGIN;
CREATE TABLE "blog_authors" (
    "id" serial NOT NULL PRIMARY KEY,
    "first_name" text NOT NULL,
    "last_name" text NOT NULL,
    "email" text NOT NULL
);
CREATE TABLE "blog_articles" (
    "id" serial NOT NULL PRIMARY KEY,
    "title" text NOT NULL,
    "content" text NOT NULL,
    "publish_date" timestamp with time zone NOT NULL,
    "author_id" integer NOT NULL REFERENCES "blog_authors" ("id")
);
CREATE TABLE "blog_comments" (
    "id" serial NOT NULL PRIMARY KEY,
    "title" text NOT NULL,
    "content" text NOT NULL,
    "publish_date" timestamp with time zone NOT NULL,
    "author_id" integer NOT NULL REFERENCES "blog_authors" ("id"),
    "related_article_id" integer NOT NULL REFERENCES "blog_articles"
("id")
);
COMMIT;

# so far so good
# then...

bastion:~ nick$ python dev/django-projects/myblog/manage.py shell
Python 2.4.3 (#1, May 20 2006, 16:12:06)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from blog.models.blog import *
>>> a = Article(title='Hi', content='Double Hi', publish_date='now')
>>> a.save()
Traceback (most recent call last):
  File "<console>", line 1, in ?
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/utils/functional.py",
line 3, in _curried
    return args[0](*(args[1:]+moreargs), **dict(kwargs.items() +
morekwargs.items()))
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/meta/__init__.py",
line 1026, in method_save
    ','.join(placeholders)), db_values)
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/db/base.py",
line 10, in execute
    result = self.cursor.execute(sql, params)
IntegrityError: ERROR:  null value in column "author_id" violates
not-null constraint

INSERT INTO "blog_articles"
("title","content","publish_date","author_id") VALUES ('Hi','Double
Hi','now',NULL)

# ok. so I made a mistake. but what follows really puzzles me.

>>> me = Author(first_name='Nick', last_name='Hristov', email='[EMAIL 
PROTECTED]')
>>> me.save()
Traceback (most recent call last):
  File "<console>", line 1, in ?
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/utils/functional.py",
line 3, in _curried
    return args[0](*(args[1:]+moreargs), **dict(kwargs.items() +
morekwargs.items()))
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/meta/__init__.py",
line 990, in method_save
    cursor = db.db.cursor()
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/db/backends/postgresql.py",
line 35, in cursor
    cursor.execute("SET TIME ZONE %s", [TIME_ZONE])
ProgrammingError: ERROR:  current transaction is aborted, commands
ignored until end of transaction block

SET TIME ZONE 'GMT'

# Wtf? I guess a transaction was opened in the previous save and it was
not closed, so all of my following db queries are going to fail too? To
some degree that sounds fine, I guess... it is fail safe. But how do I
now abort the current transaction and start a fresh?

# Or do my saves get batched and executed as a transaction? Given the
previous save did not work, it should not be batched...

Thanks for the help.

Nick


X-Google-Language: ENGLISH,ASCII-7-bit
Received: by 10.54.68.15 with SMTP id q15mr171422wra;
       Sun, 21 May 2006 08:55:25 -0700 (PDT)
Return-Path: <[EMAIL PROTECTED]>
Received: from ug-out-1314.google.com ([66.249.92.168])
       by mx.googlegroups.com with ESMTP id v11si698395cwb.2006.05.21.08.55.24;
       Sun, 21 May 2006 08:55:25 -0700 (PDT)
Received-SPF: pass (googlegroups.com: domain of [EMAIL PROTECTED] designates 
66.249.92.168 as permitted sender)
DomainKey-Status: good (test mode)
Received: by ug-out-1314.google.com with SMTP id u40so1196844ugc
       for <django-users@googlegroups.com>; Sun, 21 May 2006 08:55:23 -0700 
(PDT)
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws;
       s=beta; d=gmail.com;
       
h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references;
       
b=Ikz7orIjkcoIC5EYcFskzU7RTPoPrub55vJ6asMqqq5wqDJheUCVZcUBMBbpu8hjf6E8pE8IsGORgtuuz4cdBssraOUKEr01PFMRdmgKu51146tLKc6fSNnZR+RRQaIPH9P0SJR5VSNtxYDUH7qoi0Q/SABsfD9JbDUbpPBfUNY=
Received: by 10.78.57.11 with SMTP id f11mr939422hua;
       Sun, 21 May 2006 08:55:23 -0700 (PDT)
Received: by 10.78.24.4 with HTTP; Sun, 21 May 2006 08:55:23 -0700 (PDT)
Message-ID: <[EMAIL PROTECTED]>
Date: Sun, 21 May 2006 08:55:23 -0700
From: "Nick Hristov" <[EMAIL PROTECTED]>
To: "Django users" <django-users@googlegroups.com>
Subject: Re: noobie db problems
In-Reply-To: <[EMAIL PROTECTED]>
Mime-Version: 1.0
Content-Type: text/plain
References: <[EMAIL PROTECTED]>

I forgot to mention that I am using django point release 0.91.

Nick

On 5/21/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Hey all,

I am just starting with django; I think it is really cool, a big break
from Java/Struts dev for me. Anyways, I am experimenting with a simple
blog app. So, on to some issues. Here is output:

bastion:~ nick$ python dev/django-projects/myblog/manage.py sql blog
BEGIN;
CREATE TABLE "blog_authors" (
    "id" serial NOT NULL PRIMARY KEY,
    "first_name" text NOT NULL,
    "last_name" text NOT NULL,
    "email" text NOT NULL
);
CREATE TABLE "blog_articles" (
    "id" serial NOT NULL PRIMARY KEY,
    "title" text NOT NULL,
    "content" text NOT NULL,
    "publish_date" timestamp with time zone NOT NULL,
    "author_id" integer NOT NULL REFERENCES "blog_authors" ("id")
);
CREATE TABLE "blog_comments" (
    "id" serial NOT NULL PRIMARY KEY,
    "title" text NOT NULL,
    "content" text NOT NULL,
    "publish_date" timestamp with time zone NOT NULL,
    "author_id" integer NOT NULL REFERENCES "blog_authors" ("id"),
    "related_article_id" integer NOT NULL REFERENCES "blog_articles"
("id")
);
COMMIT;

# so far so good
# then...

bastion:~ nick$ python dev/django-projects/myblog/manage.py shell
Python 2.4.3 (#1, May 20 2006, 16:12:06)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from blog.models.blog import *
>>> a = Article(title='Hi', content='Double Hi', publish_date='now')
>>> a.save()
Traceback (most recent call last):
  File "<console>", line 1, in ?
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/utils/functional.py",
line 3, in _curried
    return args[0](*(args[1:]+moreargs), **dict(kwargs.items() +
morekwargs.items()))
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/meta/__init__.py",
line 1026, in method_save
    ','.join(placeholders)), db_values)
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/db/base.py",
line 10, in execute
    result = self.cursor.execute(sql, params)
IntegrityError: ERROR:  null value in column "author_id" violates
not-null constraint

INSERT INTO "blog_articles"
("title","content","publish_date","author_id") VALUES ('Hi','Double
Hi','now',NULL)

# ok. so I made a mistake. but what follows really puzzles me.

>>> me = Author(first_name='Nick', last_name='Hristov', email='[EMAIL 
PROTECTED]')
>>> me.save()
Traceback (most recent call last):
  File "<console>", line 1, in ?
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/utils/functional.py",
line 3, in _curried
    return args[0](*(args[1:]+moreargs), **dict(kwargs.items() +
morekwargs.items()))
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/meta/__init__.py",
line 990, in method_save
    cursor = db.db.cursor()
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/db/backends/postgresql.py",
line 35, in cursor
    cursor.execute("SET TIME ZONE %s", [TIME_ZONE])
ProgrammingError: ERROR:  current transaction is aborted, commands
ignored until end of transaction block

SET TIME ZONE 'GMT'

# Wtf? I guess a transaction was opened in the previous save and it was
not closed, so all of my following db queries are going to fail too? To
some degree that sounds fine, I guess... it is fail safe. But how do I
now abort the current transaction and start a fresh?

# Or do my saves get batched and executed as a transaction? Given the
previous save did not work, it should not be batched...

Thanks for the help.

Nick



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to