Hmmm.  Perhaps I oversimplified my code for the example.  The
workorderlines_rowid isn't actually a primary key; given the following
code where it is not one:

from sqlalchemy import *

db = create_engine('postgres://[EMAIL PROTECTED]:5432/fleettest')

db.echo = True

metadata = BoundMetaData(db)

workorderlines_table = Table('workorderlines', metadata,
        Column('company', Integer, nullable=False, autoincrement=False),
        Column('store', Integer, nullable=False, autoincrement=False),
        Column('barcode', Numeric(10,0)),
        Column('workorder', Integer, nullable=False, autoincrement=False),
        Column('line', Integer, nullable=False, autoincrement=False),
        Column('suffix', Unicode(1), nullable=False, default=''),
        Column('workorderlines_rowid', Numeric(10,0),
default=Sequence('workorderlines_rowid_seq')),
        PrimaryKeyConstraint('company', 'store', 'workorder', 'line',
'suffix'),
)

class Workorder_Line(object):
    def __repr__(self):
       return "Workorder_Line: %d %d %d %d%s" % (
           self.company, self.store, self.workorder, self.line,
self.suffix)


mapper(Workorder_Line, workorderlines_table)

def main():
    session = create_session()
    obj = Workorder_Line()
    session.save(obj)
    session.flush()

if __name__ == '__main__': main()


sqlalchemy.exceptions.SQLError: (ProgrammingError) can't adapt 'INSERT
INTO workorderlines (company, store, barcode, workorder, line, suffix,
workorderlines_rowid) VALUES (%(company)s, %(store)s, %(barcode)s, %
(workorder)s, %(line)s, %(suffix)s, %
(workorderlines_rowid)s)' {'suffix': '', 'workorderlines_rowid':
Sequence('workorderlines_rowid_seq',start=None,increment=None,optional=False),
'company': None, 'barcode': None, 'line': None, 'workorder': None,
'store': None}

is the error given.  I'd expect to get an error on not having
specified values for the primary key fields, but it appears instead to
be confused with the sequence object it's getting for the
workorderlines_rowid field.

On Jun 8, 11:49 am, Michael Bayer <[EMAIL PROTECTED]> wrote:
> On Jun 8, 11:27 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
>
>
> > Hello.  I am receiving the error:
>
> > sqlalchemy.exceptions.SQLError: (ProgrammingError) can't adapt 'INSERT
> > INTO workorderlines (workorderlines_rowid) VALUES (%
> > (workorderlines_rowid)s)' {'workorderlines_rowid':
> > Sequence('workorderlines_rowid_seq',start=None,increment=None,optional=False)}
>
> > running the following simplified version of what I am working with:
>
> > from sqlalchemy import *
>
> > db = create_engine('postgres://[EMAIL PROTECTED]:5432/fleettest')
>
> > db.echo = True
>
> > metadata = BoundMetaData(db)
>
> > workorderlines_table = Table('workorderlines', metadata,
> >         Column('workorderlines_rowid', Numeric(10,0),
> > default=Sequence('workorderlines_rowid_seq')),
> >         PrimaryKeyConstraint('workorderlines_rowid'),
> > )
>
> the "default" keyword argument is for literal values or python
> functions.  to use Sequence:
>
> t = Table('foo', metadata, Column('id', Integer,
> Sequence('my_sequence'), primary_key=True))
>
> the postgres dialect currently has the restriction that PK values must
> go in as explicitly inserted values, as opposed to a default firing
> off implicitly on the PG side.  this is documented 
> here:http://www.sqlalchemy.org/docs/metadata.html#metadata_defaults_passiv...


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

Reply via email to