bmuller / twistar

Twistar is an object-relational mapper (ORM) for Python that uses the Twisted library to provide asynchronous DB interaction.
http://findingscience.com/twistar
Other
132 stars 38 forks source link

toHash() all #65

Closed morfair closed 8 years ago

morfair commented 8 years ago

How to make obj.toHash(all) without specify all columns?

bmuller commented 8 years ago

You could get the columns/attributes using https://github.com/bmuller/twistar/blob/master/twistar/dbconfig/base.py#L311 and then call toHash. Otherwise, just use dir(obj) and pull out the ones you want.

morfair commented 8 years ago

@bmuller Sometimes columns can be very much. I do not want to specify its manually.

morfair commented 8 years ago

@bmuller On what obj I should call getSchema? Can I get example?

bmuller commented 8 years ago

After initializing the Registry use Registry.getConfig().getSchema(tablename). See http://findingscience.com/twistar/apidoc/twistar.dbconfig.base.InteractionBase.html#getSchema for more information.

morfair commented 8 years ago

@bmuller I did this in @inlineCallbacks function (def): q = yield Registry.getConfig().getSchema("clients") print q

And got empty arr []

bmuller commented 8 years ago

@morfair If you think you've found a bug, please open a ticket and make sure to include your entire script demonstrating the issue. Thanks!