id rather keep the sequence name explicit, like:
employees = Table('employees', engine,
Column('employee_id', Integer, Sequence('whatver_the_seq_name_is'),
primary_key =True),
autoload=True)
feel free to submit whatever that digs into postgres' internal
structures, although this would be quite messy as the reflection is
using information_schema currently and youd have to crack that open
(thus slowing down PG reflection even more)...doesnt seem much like
its worth it ?
On Apr 17, 2006, at 4:28 AM, William K. Volkman wrote:
Hello,
I'm using SQLAlchemy 0.1.6. I was working my way through
the documentation (taking a couple of side trips on the way ;-).
Anyway I performed this sequence:
from sqlalchemy import *
engine = create_engine('postgres://database=sat&user=wkv')
departments = Table('departments', engine,
Column('department_id', Integer, primary_key=True),
Column('department_name', String(40), nullable=False))
employees = Table('employees', engine,
Column('employee_id', Integer, primary_key=True),
Column('employee_name', String(60), nullable=False, key='name'),
Column('employee_dept', Integer,
ForeignKey("departments.department_id"))
)
departments.create()
employees.create()
engine.commit()
employees.drop()
employees.create()
employees.insert().execute(name='fred')
exit python
-- Worked fine however:
from sqlalchemy import *
engine = create_engine('postgres://database=sat&user=wkv')
employees = Table('employees', engine, autoload=True)
employees.drop()
employees.create()
employees.insert().execute(employee_name='fred')
Returned the error:
SQLError: (ProgrammingError) ERROR: relation
"public.employees_employee_id_seq" does not exist
select nextval('public.employees_employee_id_seq'::text) "select
nextval('public.employees_employee_id_seq'::text)" {}
psql (PostgreSQL) 8.0.7.
Admittedly one of those thorny special case problems.
If you use create sequence followed by create table then the two
exist independently. Using create table with serial gives you a
dependent object that gets dropped when the table is dropped.
Tracking back on pg_depends might look like:
select relname from pg_class
where relfilenode in (select objid from pg_depend
where refobjid=(select relfilenode from pg_class
where relname='employees'));
will return the name of the sequence if it's dependent
on the table.
HTH,
William.
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting
language
that extends applications into web and mobile media. Attend the
live webcast
and join the prime developer group breaking into this new coding
territory!
http://sel.as-us.falkag.net/sel?
cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users