2014-12-11 13:35 GMT-03:00 dewey <de...@pathoz.com>:
>
> I'm importing lots of text files, using csv.dictReader
>
> I then create model instances and store the recs in the DB
>
> One row from the csv file might represent a child-row, plus 4-5 parents
> (using get_or_create for these)
>
> It would be highly convenient for me if I could disable the safety
> mechanism that prevents a constructor dict from containing keys belonging
> to other tables.
>
> I'd rather not have to split my imported row-dictionary into 5-6 other
> dictionaries before calling each constructor
>
> In other words, I'd like to override __init__ on the base (or 1st mixin)
> constructor to allow (and ignore) non-column named keys in the dict passed
> as 1st constructor param
> Can someone show me how to do this??
>
> I'm using declarative and I'm not sure if this helps, but all of my model
> objects have a __prefix__ class var that tells me the first 4 chars of my
> column names.
> So, all of my column (except the pkey and modification_dttm which are
> declared in the base class & I've not figured out how to name them
> dynamicaly at class construction), names begin with a consistent prefix.
> I'd love to learn how to do dynamic naming of columns from an inherited
> parent class also but that's a separate post....
>
> For example:
>
> Class:  Customer
> Table:  cus_customers
> Cols:    cus_first, cus_last, cus_dob
>
> --
>


Check the constructor parameter for declarative_base, that should do the
trick:
http://docs.sqlalchemy.org/en/rel_0_9/orm/extensions/declarative.html?highlight=declarative_base#sqlalchemy.ext.declarative.declarative_base

-- 
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/d/optout.

Reply via email to