On 3/8/07, Christoph Haas <[EMAIL PROTECTED]> wrote:
> Hi, list...
>
> formerly I had declared my models explicitly in models/__init__.py:
>
> ============================
> from sqlalchemy import *
> from sqlalchemy.ext.assignmapper import assign_mapper
>
> powerdns_domains_table = Table(
> 'domains', meta,
> Column('id', Integer, primary_key=True), # gets a sequence assigned
> Column('name', String(255), nullable=False, unique=True),
> Column('master', String(20), default=null),
> Column('last_check', Integer),
> Column('type', String(6), nullable=False),
> Column('notified_serial', Integer),
> Column('account', String(40)),
> schema='powerdns'
> )
> ============================
>
> Since the database is present anyway and I feel no need to create it in
> websetup.py I decided that I want to simplify the code and use autoload:
>
> ============================
> powerdns_domains_table = Table('domains', meta, autoload=True,
> schema='powerdns')
> ============================
>
> Unfortunately that leads to the following exception:
>
> sqlalchemy.exceptions.ArgumentError: Could not assemble any primary key
> columns for mapped table 'domains'
>
> Funnily that error is rotating, too. Every time I reload a page in my
> browser I get an exception complaining about one of the other tables I
> define.
>
> This is the schema:
>
> ============================
> CREATE TABLE powerdns.domains
> (
> id serial NOT NULL,
> name varchar(255) NOT NULL,
> master varchar(20),
> last_check int4,
> "type" varchar(6) NOT NULL,
> notified_serial int4,
> account varchar(40),
> CONSTRAINT domains_pkey PRIMARY KEY (id),
> CONSTRAINT domains_name_key UNIQUE (name)
> )
> ============================
>
> So there is definitely a primary key.
>
> Any thoughts?
>
> Christoph
> (who feels like a marble in a tarpit currently because every change leads
> to new "interesting" problems)
Is that really the best way to declare a primary key in your database?
I bet this is something easily answered on the SQLAlchemy list.
Best Regards,
-jj
--
http://jjinux.blogspot.com/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---