Yep.  Works with postgresql:
$ python /tmp/testthis.py
2010-04-15 12:40:03,032 INFO sqlalchemy.engine.base.Engine.0x...240c
select version()
2010-04-15 12:40:03,032 INFO sqlalchemy.engine.base.Engine.0x...240c
{}
2010-04-15 12:40:03,053 INFO sqlalchemy.engine.base.Engine.0x...240c
select current_schema()
2010-04-15 12:40:03,053 INFO sqlalchemy.engine.base.Engine.0x...240c
{}
2010-04-15 12:40:03,119 INFO sqlalchemy.engine.base.Engine.0x...240c
select relname from pg_class c join pg_namespace n on
n.oid=c.relnamespace where n.nspname=current_schema() and
lower(relname)=%(name)s
2010-04-15 12:40:03,119 INFO sqlalchemy.engine.base.Engine.0x...240c
{'name': u'category'}
2010-04-15 12:40:03,211 INFO sqlalchemy.engine.base.Engine.0x...240c
CREATE TABLE category (
        name VARCHAR(64) NOT NULL,
        CONSTRAINT name PRIMARY KEY (name)
)


2010-04-15 12:40:03,211 INFO sqlalchemy.engine.base.Engine.0x...240c
{}
2010-04-15 12:40:03,630 INFO sqlalchemy.engine.base.Engine.0x...240c
COMMIT
2010-04-15 12:40:03,633 INFO sqlalchemy.engine.base.Engine.0x...240c
ALTER TABLE category DROP CONSTRAINT name
2010-04-15 12:40:03,633 INFO sqlalchemy.engine.base.Engine.0x...240c
{}
2010-04-15 12:40:03,676 INFO sqlalchemy.engine.base.Engine.0x...240c
COMMIT

-Gerry


On Apr 15, 12:18 pm, Michael Bayer <mike...@zzzcomputing.com> wrote:
> On Apr 15, 2010, at 11:46 AM, Gerry Reno wrote:
>
>
>
>
>
> > Upgraded to beta3.
>
> > So you're saying that if we want to be able to drop a constraint later
> > on we must create it with a name.
> > Alright.  But I am still getting an Operational Error:
>
> > ################################################
> > #!/usr/bin/env python
>
> > import sqlalchemy
> > from sqlalchemy import Table, Column, MetaData
> > from sqlalchemy.schema import *
> > from sqlalchemy.types import *
>
> > from sqlalchemy import create_engine
> > engine = create_engine('sqlite:///:memory:', echo=True)
>
> > metadata = MetaData()
>
> > category = Table('category', metadata,
> >    Column('name', String (64), nullable=False ),
> >    PrimaryKeyConstraint('name', name='name'),
> > )
>
> > metadata.create_all(engine)
>
> > from sqlalchemy.schema import DropConstraint
>
> > engine.execute(DropConstraint(category.constraints.pop()))
>
> >    cursor.execute(statement, parameters)
> > sqlalchemy.exc.OperationalError: (OperationalError) near "DROP":
> > syntax error u'ALTER TABLE category DROP CONSTRAINT name' ()
>
> > What am I doing wrong here?
>
> SQLite doesn't support ALTER TABLE.
>
>
>
>
>
> > -Gerry
>
> > On Apr 15, 12:28 am, Michael Bayer <mike...@zzzcomputing.com> wrote:
> >> don't know why you'd be using beta1 when we're up to beta3.....heres  a 
> >> fully working example:
>
> >> from sqlalchemy import *
> >> from sqlalchemy.schema import *
>
> >> metadata = MetaData()
>
> >> c1 = Table('category', metadata,
> >>    Column('name', String (64), nullable=False ),
> >>    PrimaryKeyConstraint('name', name='somename')
> >> )
>
> >> c2 = Table('category2', metadata,
> >>    Column('name', String (64), nullable=False ),
> >>    Column('name2', String (64), nullable=False ),
> >>    PrimaryKeyConstraint('name', 'name2', name='somename')
> >> )
>
> >> print DropConstraint(c1.constraints.pop())
> >> print DropConstraint(c2.constraints.pop())
>
> >> On Apr 14, 2010, at 9:40 PM, Gerry Reno wrote:
>
> >>> Ok, I tried with the keyword but I get this using 0.6beta1:
>
> >>>    PrimaryKeyConstraint(id='id'),
> >>>  File "/usr/lib/python2.5/site-packages/sqlalchemy/schema.py", line
> >>> 1391, in __init__
> >>>    super(ColumnCollectionConstraint, self).__init__(**kw)
> >>> TypeError: __init__() got an unexpected keyword argument 'id'
>
> >>> -Gerry
>
> >>> On Apr 14, 9:28 pm, Gerry Reno <gr...@verizon.net> wrote:
> >>>> What do I do then for a composite primary key?
>
> >>>> PrimaryKeyConstraint('col1','col2')
>
> >>>> -Gerry
>
> >>>> On Apr 14, 9:13 pm, Michael Bayer <mike...@zzzcomputing.com> wrote:
>
> >>>>> PrimaryKeyConstraint(name='name')
>
> >>>>> On Apr 14, 2010, at 8:22 PM, Gerry Reno wrote:
>
> >>>>>> category = Table('category', metadata,
> >>>>>>    Column('name', String (64), nullable=False ),
> >>>>>>    ...
> >>>>>>    PrimaryKeyConstraint('name'),
> >>>>>> )
>
> >>> --
> >>> You received this message because you are subscribed to the Google Groups 
> >>> "sqlalchemy" group.
> >>> To post to this group, send email to sqlalch...@googlegroups.com.
> >>> To unsubscribe from this group, send email to 
> >>> sqlalchemy+unsubscr...@googlegroups.com.
> >>> For more options, visit this group 
> >>> athttp://groups.google.com/group/sqlalchemy?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "sqlalchemy" group.
> > To post to this group, send email to sqlalch...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > sqlalchemy+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/sqlalchemy?hl=en.

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

Reply via email to