Apologies if I'm posting a question to this group incorrectly or with bad 
etiquette. I've been reading the emails from this group for a few years and now 
have a question myself. 

I am automating the creation of our models and business objects by reading a 
schema definition from YAML. We use the declarative base, some metaclasses and 
superclasses, a couple of mixes.. and ultimately PostgreSQL 9.x (exclusively)

I create a custom type using a metaclass that creates the primary key column 
along with anything else, and decorate anything that needs `@declared_attr` 
appropriately, for the declarative mechanism to discover it. 

Long story short,

I would like to create custom sequences using Sequence() with a start value, 
using a declared Column, and not having to construct a Table itself, as 
described in the docs here 
http://docs.sqlalchemy.org/en/latest/dialects/postgresql.html

I would like to do something like this:

class User(object):
        id = Column(Integer, Sequence('user_id_seq', start=10000), 
primary_key=True)

This does work, and emits the CREATE SEQUENCE, but does not set the owned table 
or the column to user.id

I get around this by using the default SERIAL, using DDL events, by updating 
the normal ALTER SEQUENCE [user_id_seq]  RESTART WITH [value]. 

However, I may have just missed something or misunderstood something deep in 
declarative.

My goal is to automate as much of the schema, model, and business object 
creation as possible using our DSL, which is leveraging the power of 
SQLAlchemy, GeoAlchemy2, PostgreSQL, and PostGIS.

Much obliged for any help,

Mat






-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to