Oh, I guess I was completely mis-reading the docs

You are saying I just teach the base class to use my own function 
(exclusively) for __init__ 
and I totally don't need to worry about calling the sqlalchemy internal 
(superclass) __init__ method

I was thinking I needed to call super and was trying this below but now I 
see I was misunderstanding the docs

   def __init__(self, *args, **kwargs):
        '''  filters out cols that dont match the table
            and then call the built-in constructor
        '''
        if args[0] and isinstance(args[0], dict):
            colDict = subsetOfConstrVals(self.__class__, args[0])
            _declarative_constructor(self, **colDict)
        else:
            _declarative_constructor(self, **kwargs)




On Thursday, December 11, 2014 10:45:00 AM UTC-6, Mariano Mara wrote:
>
>
>
> 2014-12-11 13:35 GMT-03:00 dewey <[email protected] <javascript:>>:
>>
>> 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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to