[sqlalchemy] Re: result as the dict()

2008-07-06 Thread Michael Bayer
On Jul 6, 2008, at 1:16 AM, Empty wrote: You might want to look into the new instrument_declarative function in 0.5. It allows you to wrap a class with the declarative functionality without using the metaclass. This should permit you to work with a subclass, although I haven't tried it.

[sqlalchemy] Re: access the fields in a record as a dict

2008-07-06 Thread alex bodnaru
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 hi ilya, everybody, that time, i was using elixir and not the select() function in sa. elixir.query.filter() returned a list of objects, with their fields as attributes (same as the entity definition in elixir). thus, to have each record

[sqlalchemy] Re: IDEA: Call-local vs thread-local context

2008-07-06 Thread Iwan
On Jul 4, 3:41 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Jul 4, 2008, at 5:40 AM, Iwan wrote: Assume also that CC.get_context_hash() returns id(CC.get_context()) Session = scoped_session(sessionmaker(), scopefunc=CC.get_context_hash) if get_context_hash returns a dict, thats

[sqlalchemy] Re: IDEA: Call-local vs thread-local context

2008-07-06 Thread Michael Bayer
On Jul 6, 2008, at 5:08 AM, Iwan wrote: On Jul 4, 3:41 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Jul 4, 2008, at 5:40 AM, Iwan wrote: Assume also that CC.get_context_hash() returns id(CC.get_context()) Session = scoped_session(sessionmaker(), scopefunc=CC.get_context_hash) if

[sqlalchemy] how query.count() works?

2008-07-06 Thread az
i have some tree-walking query via many2many, having configurable levels of hops to look into. and it returns very different results for len(query) and query.count(): len() stays constant above the depth of the tree (correct), while .count() keeps growing an growing. what's can be wrong?

[sqlalchemy] Re: how query.count() works?

2008-07-06 Thread Michael Bayer
On Jul 6, 2008, at 11:33 AM, [EMAIL PROTECTED] wrote: i have some tree-walking query via many2many, having configurable levels of hops to look into. and it returns very different results for len(query) and query.count(): len() stays constant above the depth of the tree (correct),

[sqlalchemy] Re: how query.count() works?

2008-07-06 Thread az
the query is ugly; seems count(1) counts the decart-product or something: SA: INFO SELECT count(1) AS count_1 FROM Otnoshenie, mm_nazn2rabmesto, mm_nazn2pozicia, mm_pozicia2otdel, mm_otdel2otdel AS mm_otdel2otdel, mm_otdel2otdel AS mm_otdel2otdel1, mm_otdel2otdel AS mm_otdel2otdel2,

[sqlalchemy] Re: result as the dict()

2008-07-06 Thread Russell Warren
it also accepts cls as a keyword argument which is used as the base class: Base = declarative_base(..., cls=MyMixin) you can also add a mixin to any class in Python like: Base = declarative_base(...) MyBase = type(MyBase, (Base, MyMixin), {}) Thanks! Both are

[sqlalchemy] Re: how query.count() works?

2008-07-06 Thread Michael Bayer
On Jul 6, 2008, at 12:21 PM, [EMAIL PROTECTED] wrote: the query is ugly; seems count(1) counts the decart-product or something: SA: INFO SELECT count(1) AS count_1 FROM Otnoshenie, mm_nazn2rabmesto, mm_nazn2pozicia, mm_pozicia2otdel, mm_otdel2otdel AS mm_otdel2otdel, mm_otdel2otdel AS

[sqlalchemy] Re: how query.count() works?

2008-07-06 Thread az
On Sunday 06 July 2008 21:33:49 Michael Bayer wrote: On Jul 6, 2008, at 12:21 PM, [EMAIL PROTECTED] wrote: the query is ugly; seems count(1) counts the decart-product or something: SA: INFO SELECT count(1) AS count_1 FROM Otnoshenie, mm_nazn2rabmesto, mm_nazn2pozicia,

[sqlalchemy] nullable=False by default

2008-07-06 Thread Kless
Is possible create the fields with nullable=False by default? It's heavy to have to add this to each field. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to

[sqlalchemy] Re: nullable=False by default

2008-07-06 Thread Kless
And, why can I add 'default' -- def Column0(*a, **k): return Column(nullable=False, default='', *a, **k) -- it shows the next error: TypeError: _FigureVisitName object got multiple values for keyword argument 'default' On Jul 6, 7:53 pm, [EMAIL PROTECTED] wrote: u can

[sqlalchemy] Re: nullable=False by default

2008-07-06 Thread Kless
I'm using so: def Column0(*a, **k): return Column(nullable=False, default='', *a, **k) groups_table = Table('foo', metadata, Column0('id', Integer, primary_key=True), Column0('bar', Unicode(16)), ) Note: I'm using SA 0.5 beta. But well, that solved it. Thank you

[sqlalchemy] Re: nullable=False by default

2008-07-06 Thread Kless
I think that there is a bug. autoincrement doesn't works with *default=''* Any solution to this problem? On Jul 6, 10:46 pm, Kless [EMAIL PROTECTED] wrote: I'm using so: def Column0(*a, **k):     return Column(nullable=False, default='', *a, **k) groups_table = Table('foo',

[sqlalchemy] _is_oid

2008-07-06 Thread Kless
Does anybody could say anything more? Defaults to False: used internally to indicate that this column is used as the quasi-hidden oid column --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post

[sqlalchemy] Re: _is_oid

2008-07-06 Thread Michael Bayer
the underscore here means, doesn't do what you'd want it to. explicit oid support is likely to be removed soon. On Jul 6, 2008, at 7:35 PM, Kless wrote: Does anybody could say anything more? Defaults to False: used internally to indicate that this column is used as the quasi-hidden oid

[sqlalchemy] Re: nullable=False by default

2008-07-06 Thread Michael Bayer
On Jul 6, 2008, at 7:06 PM, Kless wrote: I think that there is a bug. autoincrement doesn't works with *default=''* Any solution to this problem? the docs for autoincrement need to be read closely. This flag only applies to Integer columns with the primary key flag set. I'm not

[sqlalchemy] Re: result as the dict()

2008-07-06 Thread Russell Warren
Spoke a bit to soon... looks like that cls argument is only available in 0.5, and the type() mixin trick still complains about not having a mapped_table specifed. SQLA 0.4.6 is unhappy with the snippet below... import sqlalchemy as sa from sqlalchemy.ext.declarative import declarative_base