Re: [sqlalchemy] avoid setting attribute on init and or.reconstructor

2020-11-17 Thread lars van gemerden
if obj is None: > return self > obj.__dict__[self.__name__] = result = self.fget(obj) > return result > > > then you can just set it up as: > > class Planning(...): > @memoized_property > def matrix(self): > return self.matrix

Re: [sqlalchemy] avoid setting attribute on init and or.reconstructor

2020-11-16 Thread lars van gemerden
Hi Mike, What if during reconstruction you need a one-to-many attribute, like: class Planning(SqlaBase): stops = relationship("Stop", back_populates="planning", lazy="joined") matrix_factory = Matrix def __init__(self, **kwargs): super().__init__(**kwargs)

Re: [sqlalchemy] join aliased

2014-03-25 Thread lars van gemerden
OK, thank you On Saturday, March 22, 2014 9:03:01 PM UTC+1, Michael Bayer wrote: On Mar 22, 2014, at 9:16 AM, lars van gemerden la...@rational-it.comjavascript: wrote: query = session.query(Email) query = query.join(user) #or query = query.join(user, aliased = True

[sqlalchemy] a relationship question

2014-03-25 Thread lars van gemerden
Hi all, Simple question, but couldn't find it in the docs: - How can i retrieve the target class in a relationship in the ORM? Say i have a sqla class with a relationship(User, primaryjoin = ...), how can i retrieve the User class from the relationship ('relationship' is a descriptor, right?)

[sqlalchemy] join aliased

2014-03-22 Thread lars van gemerden
Hi all, Maybe (hopefully;-) i am missing something simple, but i have the following test code: engine = create_engine('sqlite:///:memory:', echo=True) Session = sessionmaker(bind=engine) Base = declarative_base() class User(Base):

[sqlalchemy] Re: label column_descriptions

2014-03-20 Thread lars van gemerden
I solved it (again): for future reference: say you have the expression Person.name (Person is SQLA class) to use in a query, to have a label show up under that name in the resulting KeyedTuple's: to do: Person.name.label(something) is not enough, you have to do: expr =

[sqlalchemy] Re: label column_descriptions

2014-03-20 Thread lars van gemerden
thanks, Michael, we crossed responses; i thought it was something like that, but there are some gotchas (at least for me; see above). CL On Thursday, March 20, 2014 2:22:24 PM UTC+1, lars van gemerden wrote: I solved it (again): for future reference: say you have the expression

Re: [sqlalchemy] label column_descriptions

2014-03-20 Thread lars van Gemerden
, 2014 at 4:28 PM, Michael Bayer mike...@zzzcomputing.comwrote: On Mar 20, 2014, at 9:22 AM, lars van gemerden l...@rational-it.com wrote: I solved it (again): for future reference: say you have the expression Person.name (Person is SQLA class) to use in a query, to have a label show

Re: [sqlalchemy] AssertionError

2014-03-19 Thread lars van gemerden
clear and bug found .. thanks On Tuesday, March 18, 2014 4:51:36 PM UTC+1, Michael Bayer wrote: it means this: a1 = A(id=1) session.add(a1) session.commit() a2 = A(id=1) session.add(a2) # — error On Mar 18, 2014, at 9:59 AM, lars van gemerden la...@rational-it.comjavascript

[sqlalchemy] AssertionError

2014-03-18 Thread lars van gemerden
Hi all, Does anyone know hoe to interpret the following error? AssertionError: A conflicting state is already present in the identity map for key (class 'models.data.database.Keuze', (1,)) Cheers, Lars -- You received this message because you are subscribed to the Google Groups

Re: [sqlalchemy] StaleDataError/ObjectDeletedError

2014-02-01 Thread lars van gemerden
, 2014, at 8:11 PM, lars van gemerden la...@rational-it.comjavascript: wrote: this means an object was meant to be UPDATEed via the ORM, however the row which is the target of the UPDATE is missing. Either the primary key of this row changed somehow, or the row was deleted, *or* the row

Re: [sqlalchemy] StaleDataError/ObjectDeletedError

2014-02-01 Thread lars van gemerden
Oh, on more question: might there be anything inherently wrong with the scoped_session approach that i showed in the code snippets above? CL On Saturday, February 1, 2014 1:25:27 PM UTC+1, lars van gemerden wrote: Thanks, this helps some to narrow it down. Trying to zoom in: - why would

Re: [sqlalchemy] StaleDataError/ObjectDeletedError

2014-02-01 Thread lars van gemerden
the problem for now (needs more testing)! Thanks for the link to the talk as well. Cheerio, Lars On Saturday, February 1, 2014 4:34:10 PM UTC+1, Michael Bayer wrote: On Feb 1, 2014, at 9:01 AM, lars van gemerden la...@rational-it.comjavascript: wrote: Oh, on more question: might

Re: [sqlalchemy] StaleDataError/ObjectDeletedError

2014-01-31 Thread lars van gemerden
Hi Michael, With some more detail: What i do is: 1 make a new object (mapped)- obj1 2 create a scoped session (with context manager)- session1 3 do session1.add(obj) 4 create another scoped session - session2 5 do session2.query(someclass).get(some_id)-obj2 6 close session2, no commit, no

[sqlalchemy] keyword search

2013-12-17 Thread lars van gemerden
Hi all, I want to implement a keyword search over multiple fields and/or even related tables. Tables/orm classes are not designed by me but by users of my software, so i will probably let them indicate whether a field/relationship should be included (or I'll base it on type, e.g. String and

[sqlalchemy] Re: keyword search

2013-12-17 Thread lars van gemerden
PS: a search over all fields would be great too! On Tuesday, December 17, 2013 11:01:51 AM UTC+1, lars van gemerden wrote: Hi all, I want to implement a keyword search over multiple fields and/or even related tables. Tables/orm classes are not designed by me but by users of my software

Re: [sqlalchemy] nullable/association question

2013-11-21 Thread lars van Gemerden
. On Nov 20, 2013, at 8:02 AM, lars van gemerden l...@rational-it.com wrote: Hi all, I have 2 sqla classes with mapped tables: User and Role with a many to many relationship (User.roles/Role.users) through an association table. User has columns email and password, both non nullable. I create

Re: [sqlalchemy] just a picture

2013-11-21 Thread Lars van Gemerden
The tool Lars van Gemerden l...@rational-it.com +31 6 26 88 55 39 On 21 nov. 2013, at 15:02, Stefane Fermigier s...@fermigier.com wrote: Hi Lars, Are you working on the tool, or on the application whose schema

Re: [sqlalchemy] just a picture

2013-11-21 Thread Lars van Gemerden
, not to be a modelling tool with the reach of sqla itself. Cheers, Lars Lars van Gemerden l...@rational-it.com +31 6 26 88 55 39 On 21 nov. 2013, at 15:19, Werner werner...@gmx.ch wrote: On 21/11/2013 15:02, Stefane

[sqlalchemy] just a picture

2013-11-21 Thread lars van gemerden
something i have been working on, running on sqlalchemy . https://lh4.googleusercontent.com/-xwar8HEk2iU/Uo39bYo9x_I/AD4/AoTurWbGJ30/s1600/dbpic.png Cheers, Lars -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from

Re: [sqlalchemy] nullable/association question

2013-11-21 Thread lars van gemerden
, November 21, 2013 3:57:44 PM UTC+1, Michael Bayer wrote: I’d stick with judicious use of “with session.no_autoflush: around the block where the User is being constructed and isn’t ready to flush yet. On Nov 21, 2013, at 6:29 AM, lars van Gemerden la...@rational-it.comjavascript: wrote

[sqlalchemy] nullable/association question

2013-11-20 Thread lars van gemerden
Hi all, I have 2 sqla classes with mapped tables: User and Role with a many to many relationship (User.roles/Role.users) through an association table. User has columns email and password, both non nullable. I create an instance of User but do not commit it yet, next i do a query on Role:

[sqlalchemy] quick query question

2013-10-28 Thread lars van gemerden
Hi, Short question: when does e.g. query.all() returns a list of objects and when it returns a list of NamedTuple's? is it only after you call add_columns() on the query that all() starts returning NamedTuple's? Cheers, Lars -- You received this message because you are subscribed to the

Re: [sqlalchemy] quick query question

2013-10-28 Thread Lars van Gemerden
Thanks again .. Lars van Gemerden l...@rational-it.com +31 6 26 88 55 39 On 28 okt. 2013, at 18:12, Michael Bayer mike...@zzzcomputing.com wrote: the list of objects are for when the query is set to return exactly one

Re: [sqlalchemy] quelified/disambiguated column names in query

2013-10-22 Thread lars van Gemerden
Thank you, i must have blundered over that in the docs ... Lars On Mon, Oct 21, 2013 at 11:36 PM, Michael Bayer mike...@zzzcomputing.comwrote: On Oct 21, 2013, at 5:20 PM, lars van gemerden l...@rational-it.com wrote: Hello, Say that i have a table with reports with a column 'title

[sqlalchemy] quelified/disambiguated column names in query

2013-10-21 Thread lars van gemerden
Hello, Say that i have a table with reports with a column 'title' and a one to many relationship 'chapters' to chapters also with a column 'title', if i join these tables in a query, like: q = self.session.query(Report).join(Report.chapters).add_columns(Report.title, Chapter.title,

Re: [sqlalchemy] query question

2013-09-09 Thread lars van gemerden
King wrote: On Wed, Sep 4, 2013 at 12:05 PM, lars van gemerden la...@rational-it.comjavascript: wrote: I think i must be reading over something, but: is there a way to delay the selection of attributes in a query; something like session.query(Person).filter(Person.age

Re: [sqlalchemy] query question

2013-09-09 Thread lars van Gemerden
OK, never mind |-) should be: q = q.with_entities(Report.number) q = q.add_columns(Report.number) sry On Mon, Sep 9, 2013 at 2:43 PM, lars van gemerden l...@rational-it.comwrote: Ok, i've tried both (and each separately), as in: r1 = Report(number = 1, title

[sqlalchemy] query question

2013-09-04 Thread lars van gemerden
I think i must be reading over something, but: is there a way to delay the selection of attributes in a query; something like session.query(Person).filter(Person.age 100).select(Person.name).first() (uAncient Bob,) Cheers, Lars -- You received this message because you are

Re: [sqlalchemy] error related to setting attribute to same value twice

2013-09-03 Thread lars van gemerden
) ...it works fine. Hope that helps, Simon On 2 Sep 2013, at 19:58, lars van Gemerden la...@rational-it.comjavascript: wrote: Yes I know the question was a bit vague, but i couldn't think of a simple way to show some code. A test case would probably require some major surgery

Re: [sqlalchemy] error related to setting attribute to same value twice

2013-09-03 Thread lars van Gemerden
is still not quite the same as your error message. What version of SQLAlchemy are you using? (The above was from 0.8.2) Simon On Tue, Sep 3, 2013 at 10:15 AM, lars van gemerden l...@rational-it.com wrote: I am getting that same error (not the original one). For the moment i've solved

[sqlalchemy] error related to setting attribute to same value twice

2013-09-02 Thread lars van gemerden
Hi all, I have a one-to-one and many-to-one relationship (with an association table in the middle; Report.author-assoctable-Person.reports; why the table in the middle, you might ask, well it's a long story) and i am setting the author on a specific Report twice to the same value. This gives

Re: [sqlalchemy] error related to setting attribute to same value twice

2013-09-02 Thread Lars van Gemerden
Well, from the message yes, but i am not setting any primary keys manually, so where could the second instance come from? CL Lars van Gemerden l...@rational-it.com +31 6 26 88 55 39 On 2 sep. 2013, at 17:39, Simon King

Re: [sqlalchemy] error related to setting attribute to same value twice

2013-09-02 Thread lars van Gemerden
from a different thread, or retrieved from a cache or something similar? Producing a standalone test script would help in diagnosing the problem. Simon On 2 Sep 2013, at 18:56, Lars van Gemerden l...@rational-it.com wrote: Well, from the message yes, but i am not setting any primary keys

[sqlalchemy] alternate way to filter queries

2013-08-26 Thread lars van gemerden
Hi all, This might be a bit of a stretch but here it goes: Say that i have a lambda function that takes a mapped object and teturns whether it is valid; e.g: lambda person: person.age 17 or person.length 1.75 is it possible to use this method to perform an sqla query on the database?

Re: [sqlalchemy] alternate way to filter queries

2013-08-26 Thread lars van gemerden
, Michael Bayer wrote: On Aug 26, 2013, at 11:14 AM, lars van gemerden la...@rational-it.comjavascript: wrote: Hi all, This might be a bit of a stretch but here it goes: Say that i have a lambda function that takes a mapped object and teturns whether it is valid; e.g: lambda person

Re: [sqlalchemy] alternate way to filter queries

2013-08-26 Thread lars van gemerden
UTC+2, Simon King wrote: On 26 Aug 2013, at 19:15, lars van gemerden la...@rational-it.comjavascript: wrote: On Monday, August 26, 2013 5:23:07 PM UTC+2, Michael Bayer wrote: On Aug 26, 2013, at 11:14 AM, lars van gemerden la...@rational-it.com wrote: Hi all

Re: [sqlalchemy] possible bug in InstrumentedAttribute.__delete__?

2013-07-14 Thread lars van gemerden
surprise and it's not hard to do, as Wichert mentioned. Thanks again, Michael, my code improves ... Lars On Saturday, July 13, 2013 10:59:08 PM UTC+2, Michael Bayer wrote: On Jul 13, 2013, at 3:21 PM, Lars van Gemerden la...@rational-it.comjavascript: wrote: Just trying to help; i am

Re: [sqlalchemy] possible bug in InstrumentedAttribute.__delete__?

2013-07-13 Thread Lars van Gemerden
in my code, just something i ran into while cleaning up some internal api, as you say i can easily work around it. Cheers, Lars Lars van Gemerden l...@rational-it.com +31 6 26 88 55 39 On 13 jul. 2013, at 01:52, Michael

Re: [sqlalchemy] possible bug in InstrumentedAttribute.__delete__?

2013-07-13 Thread Lars van Gemerden
there are disadvantages. Cheers, Lars Lars van Gemerden l...@rational-it.com +31 6 26 88 55 39 On 13 jul. 2013, at 20:02, Michael Bayer mike...@zzzcomputing.com wrote: On Jul 13, 2013, at 10:24 AM, Lars van Gemerden l...@rational

[sqlalchemy] possible bug in InstrumentedAttribute.__delete__?

2013-07-12 Thread lars van gemerden
Hi all, I had an arror in my code and i think i have reconstructed it as follows: --- from sqlalchemy import Column, Integer, String from sqlalchemy import create_engine from

Re: [sqlalchemy] possible bug in InstrumentedAttribute.__delete__?

2013-07-12 Thread Lars van Gemerden
Can i just override __delattr__ in a subclass of a declarative base to achieve this anyway? Cheers, Lars Lars van Gemerden l...@rational-it.com +31 6 26 88 55 39 On 12 jul. 2013, at 18:28, Michael Bayer mike

Re: [sqlalchemy] possible bug in InstrumentedAttribute.__delete__?

2013-07-12 Thread Lars van Gemerden
After thinking on it some more, should InstrumentedAttribute.__delete__ even exist then, or maybe raise a NotImplementedError? CL Lars van Gemerden l...@rational-it.com +31 6 26 88 55 39 On 12 jul. 2013, at 18:28

Re: [sqlalchemy] finding table/column name of unique constraint failure

2013-05-21 Thread lars van Gemerden
Thanks, Michael On Mon, May 20, 2013 at 12:52 AM, Michael Bayer mike...@zzzcomputing.comwrote: On May 19, 2013, at 4:39 AM, lars van gemerden l...@rational-it.com wrote: Hi all, I generate webpages in which end-users can input data that is stored in a database via sqla.The datamodel

[sqlalchemy] finding table/column name of unique constraint failure

2013-05-19 Thread lars van gemerden
Hi all, I generate webpages in which end-users can input data that is stored in a database via sqla.The datamodel is not pre-defined but created by (other) users/designers. My question is how can i best let the end-user know which field contains the error if the end-user violates a unique

[sqlalchemy] adding validates() decorator after class creation

2013-01-04 Thread lars van gemerden
Hi, I am trying to use validates() to dynamically add validation to my sqla classes, but i cannot figure out how to do this. I have read python decorator docs and docs n validates, but something escapes me (or it is just not possible). A code snippet (this does not work): def

[sqlalchemy] Re: adding validates() decorator after class creation

2013-01-04 Thread lars van gemerden
Perfect (almost ;-), thanks a lot! for future reference, the attribute name (key) was needed in create_validator(cls) to access the correct validate method: @staticmethod def _create_validator(key, cls): def validate(target, value, oldvalue, initiator):

[sqlalchemy] Re: automating inheritance

2012-05-01 Thread lars van gemerden
then single table for all levels beyond that.   Depends on what you're trying to do. On Apr 27, 2012, at 3:05 AM, lars van gemerden wrote: Ok, so speed might become an issue for me as well; Do you think a similar metaclass approach would work for concrete inheritance would work

Re: [sqlalchemy] Re: automating inheritance

2012-04-27 Thread lars van gemerden
inheritance? Cheers, Lars On Friday, April 20, 2012 9:32:49 PM UTC+2, Michael Bayer wrote: On Apr 20, 2012, at 8:51 AM, lars van gemerden wrote: Ok, thank you, that helps, but now i cannot inherit from Engineer, as in: class BaseMixin(object): discriminator = Column(String(50

[sqlalchemy] Re: automating inheritance

2012-04-20 Thread lars van gemerden
On Apr 19, 4:13 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Apr 19, 2012, at 6:23 AM, lars van gemerden wrote: I am trying to my my joined inheritance code clearer, for the dynamic generation of sa classes and tried to do something like this: class InheritMixin(object

Re: [sqlalchemy] Re: automating inheritance

2012-04-20 Thread lars van gemerden
): return {'polymorphic_identity': cls.__name__} to InheritMixin instead of doing the 'has_inherited_table' if-statement in BaseMixin? Cheers, Lars On Friday, April 20, 2012 12:41:28 PM UTC+2, Michael Bayer wrote: On Apr 20, 2012, at 4:59 AM, lars van gemerden wrote

Re: [sqlalchemy] Re: automating inheritance

2012-04-20 Thread lars van gemerden
]) session.commit() people = session.query(Person).all() print people Do you see any drawbacks, gotchas for later on? Regards, Lars On Friday, April 20, 2012 12:41:28 PM UTC+2, Michael Bayer wrote: On Apr 20, 2012, at 4:59 AM, lars van gemerden wrote: this is the testcase

[sqlalchemy] automating inheritance

2012-04-19 Thread lars van gemerden
I am trying to my my joined inheritance code clearer, for the dynamic generation of sa classes and tried to do something like this: class InheritMixin(object): @declared_attr def __tablename__(cls): return cls.__name__ @declared_attr def id(cls): if cls.__name__

[sqlalchemy] Re: dynamically adding a validates method

2012-04-16 Thread lars van gemerden
.  Positive.value is an attribute generated by the mapping which is a result of using the declarative base. On Apr 15, 2012, at 1:10 PM, lars van gemerden wrote: OK, this helps, so how do i do this if i do not know the name of the attribute to be checked  in advance(the value in @validates

[sqlalchemy] Re: dynamically adding a validates method

2012-04-16 Thread lars van gemerden
PS: the validate(value) method in typedef[name] is a normal method, throwing exception on errors and returning the value when OK. On Apr 16, 2:01 pm, lars van gemerden l...@rational-it.com wrote: Thank you, i got it working now. For future reference: Before creating a sa class with something

[sqlalchemy] dynamically adding a validates method

2012-04-15 Thread lars van gemerden
Hi, I need a way to dynamically add a validates method to a already created sqla class. In a normal class declaration you can add a validator by: class Positive(Base): __tablename__ = positives value = Column(Integer) def checkvalue(self, name, value): assert value 0

[sqlalchemy] Re: dynamically adding a validates method

2012-04-15 Thread lars van gemerden
: @event.listens_for(Positive.value, set) def checkvalue(target, value, oldvalue, initiator)    assert value 0 if you want to return a new, mutated value then add retval=True to listens_for(). On Apr 15, 2012, at 8:22 AM, lars van gemerden wrote: Hi, I need a way to dynamically add a validates

[sqlalchemy] Re: dynamically adding a validates method

2012-04-15 Thread lars van gemerden
, value):     assert value 0     return value Positive = type(Positive, (Base,), dict(__tablename__ = positives,  value = Column(Integer), checkvalue=checkvalue)) On Apr 15, 2012, at 12:37 PM, lars van gemerden wrote: I don't know what @validates hangs a marker of the method

[sqlalchemy] Re: append to children in hierarchical data

2012-04-12 Thread lars van gemerden
occurs right away (is there a flush happening in the background?), while when updating the parent, the exception happens during the flush afterwards. On Apr 11, 5:41 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Apr 11, 2012, at 3:34 AM, lars van gemerden wrote: Hi all, I am

[sqlalchemy] append to children in hierarchical data

2012-04-11 Thread lars van gemerden
Hi all, I am looking for a way to append a child to a tree like structure. I am using adjacency to represent the tree. Let's say I have a relationship configured with: children = relationship(TreeNode, primaryjoin = TreeNode.id == TreeNode.parent_id,

[sqlalchemy] Re: return type of relationship

2012-03-30 Thread lars van gemerden
...@zzzcomputing.com wrote: we're working on a more documented API for getting info like this but at the moment it would be: MyClass.someattribute.property.mapper.class_ On Mar 29, 2012, at 7:16 PM, lars van gemerden wrote: I am generating xml from SAclass objects and need to get

[sqlalchemy] Re: help on SAWarning

2012-03-30 Thread lars van gemerden
Found another bug and the warning is gone; can't pinpoint why though ... On Mar 30, 1:03 am, lars van gemerden l...@rational-it.com wrote: OK, thanks, I still get the warning in some cases and i am still zooming in on the problem for a small test case. At least i have solved the problem

[sqlalchemy] Re: help on SAWarning

2012-03-29 Thread lars van gemerden
the session session.flush()   # generates warning, since ft.of_members has changed but the contents aren't in the Session Another cause could be, of_members has a cascade that doesn't include save-update, like cascade='delete' is a common mistake. On Mar 28, 2012, at 6:45 PM, lars van gemerden

[sqlalchemy] Re: help on SAWarning

2012-03-29 Thread lars van gemerden
of the IList anymore). Cheers On Mar 29, 4:20 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Mar 29, 2012, at 9:50 AM, lars van gemerden wrote: I have found that this specific behaviour (re-initialization of the InstrumentedList) does not happen if expire_on_commit = False is set

[sqlalchemy] return type of relationship

2012-03-29 Thread lars van gemerden
I am generating xml from SAclass objects and need to get the return type (referred SA class) of an relationship attribute (even if the returned value is None). The type will be used as tagname during XML generation. Can anyone tell me how to get this type? Cheers, Lars -- You received this

[sqlalchemy] Re: names of foreign keys from unknown table/class (short question)

2012-03-27 Thread lars van gemerden
with each associated ForeignKey object. On Mar 25, 2012, at 7:29 PM, lars van gemerden wrote: Hello, Does anyone know a way get the names of the foreign key columns of a table, if the table/class is unknown beforehand? I tried with Column.foreign_keys, which gives a set (why

[sqlalchemy] names of foreign keys from unknown table/class (short question)

2012-03-25 Thread lars van gemerden
Hello, Does anyone know a way get the names of the foreign key columns of a table, if the table/class is unknown beforehand? I tried with Column.foreign_keys, which gives a set (why?) of ForeignKey objects but the name attribute of ForeignKey is not automatically set. Cheers, Lars -- You

[sqlalchemy] Re: xml approach

2012-03-23 Thread lars van gemerden
Hi Julian, Thanks, I am looking into it and it looks interesting. Have you done much testing yet? How do you (plan to; haven't looked at too much detail yet) check for circular references (like backrefs)? Cheers, Lars On Thursday, March 22, 2012 11:36:41 AM UTC+1, lars van gemerden wrote

[sqlalchemy] Re: short question about primary keys

2012-03-23 Thread lars van gemerden
):     def get_pk(self):         om = object_mapper(self)         keys = [k.key for k in om.primary_key]         return tuple(getattr(self, k) for k in keys) On Fri, Mar 23, 2012 at 2:48 PM, lars van gemerden l...@rational-it.comwrote: Hi, Does anyone know a way get the the value(s

[sqlalchemy] xml approach

2012-03-22 Thread lars van gemerden
Hi, I am looking for a way to convert SQLalchemy objects to XML and back, in order to support a webapplication. I made a mixin class that does a decent job on 'normal' python objects (basically works for in the same cases as pickle, though more testing is required). I would prefer to have a

[sqlalchemy] Re: deleting a sqlite database

2012-02-27 Thread lars van gemerden
straightforward, ... or whether another approach might be more appropriate. Cheers, Lars On Feb 26, 10:47 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Feb 26, 2012, at 12:47 PM, lars van gemerden wrote: I was wrong, the method emptied the database, but I was checking the tables

[sqlalchemy] Re: short drop_all question

2012-02-25 Thread lars van gemerden
with sqlite? Chris On 24/02/2012 14:32, lars van gemerden wrote: OK, the file isn't closed ofcourse and i can't figure out how to close it. I'll try some more and if nothing works probably start a new post ... Thanks anyway, Chris On Feb 24, 3:02 pm, lars van gemerdenl

[sqlalchemy] deleting a sqlite database

2012-02-25 Thread lars van gemerden
Hi all, I looking for a way to delete/empty a sqlite database completely (can be in memory or file). I have tried: - metadata.drop_all(engine); which does not work with cyclic references - solution from http://www.sqlalchemy.org/trac/wiki/UsageRecipes/DropEverything; it requires names of

[sqlalchemy] short drop_all question

2012-02-24 Thread lars van gemerden
can it be possible that drop_all does not empty the database of there are circular references between tables? I am using sqlite. Cheers, Lars -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to

[sqlalchemy] Re: short drop_all question

2012-02-24 Thread lars van gemerden
Thanks very much, Nothing is ever easy ... :-( why not .. :-) On Feb 24, 2:11 pm, Chris Withers ch...@simplistix.co.uk wrote: On 24/02/2012 12:40, lars van gemerden wrote: can it be possible that drop_all does not empty the database of there are circular references between tables? You

[sqlalchemy] Re: short drop_all question

2012-02-24 Thread lars van gemerden
and closing and deleting the file in tearDown. Cheers, Lars On Feb 24, 2:28 pm, lars van gemerden l...@rational-it.com wrote: Thanks very much, Nothing is ever easy ... :-( why not .. :-) On Feb 24, 2:11 pm, Chris Withers ch...@simplistix.co.uk wrote: On 24/02/2012 12:40, lars van

[sqlalchemy] Re: problem with dynamic tables/classes and inheritance

2012-02-23 Thread lars van gemerden
Seems a finally got what I wanted to achieve. Changed a lot of things, so I cannot pinpoint the error(s) in the code above. If anyone is interested I will help/share the solution I found. Cheers, Lars On Feb 22, 8:35 pm, lars van gemerden l...@rational-it.com wrote: I am trying to generate

[sqlalchemy] order of initialization __mapper_args__ 'inherit_condition' and primary key

2012-02-23 Thread lars van gemerden
Hi all, I reproduced an error I was having with the code below (basically pasted from the tutorial for joined inheritance) and added an 'inherit_condition' to __mapper_args__ of the subclass. At that point the code started throwing a sqlalchemy.exc.InterfaceError. The code is:

[sqlalchemy] Re: order of initialization __mapper_args__ 'inherit_condition' and primary key

2012-02-23 Thread lars van gemerden
, '__mapper_args__': {'polymorphic_identity': name, 'inherit_condition': (id_ == classes[basename].id)}} But I am getting a (maybe unrelated) error. Should this solution work? Cheers, Lars On Feb 23, 4:07 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Feb 23, 2012, at 9:56 AM, lars van gemerden wrote

[sqlalchemy] Re: order of initialization __mapper_args__ 'inherit_condition' and primary key

2012-02-23 Thread lars van gemerden
Yep, they are the same class (i don't create any class of which i don't have the superclass yet). Thanks for your help; on to the next bug ... On Feb 23, 5:32 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Feb 23, 2012, at 10:47 AM, lars van gemerden wrote: OK, thanks

[sqlalchemy] problem with dynamic tables/classes and inheritance

2012-02-22 Thread lars van gemerden
I am trying to generate tables/classes dynamically. The code below is my latest attempt, but I cannot get it to work. - class TableName(object): @declared_attr def __tablename__(cls): return cls.__name__ class Inherit(object):

[sqlalchemy] @validates clean-up

2012-02-06 Thread lars van gemerden
I am having some trouble cleaning up after my @validates method throws an exception. The validation is of a relationship attribute and the foreign record should be removed. Are there some general tips? Otherwise I will post a code example. -- You received this message because you are subscribed

[sqlalchemy] Re: Elixir question

2012-02-05 Thread lars van gemerden
datamodel. Does anyone see any drawbacks? Cheers, Lars On Feb 5, 10:50 am, Gaëtan de Menten gdemen...@gmail.com wrote: On 02/03/2012 12:08 PM, lars van gemerden wrote: I should probably make the pair method: def pair(name1, name2):      p1, p2 = Pairs(name1), Pairs(name2)      p1

[sqlalchemy] Re: Elixir question

2012-02-05 Thread lars van gemerden
Sorry, scrap the remark about primaryjoin ... inheritance. INheritance wasn't the problem. On Feb 5, 1:27 pm, lars van gemerden l...@rational-it.com wrote: OK, thank you, I went back to SQLA and came up with this for now (simplified

[sqlalchemy] Elixir question

2012-02-03 Thread lars van gemerden
Hi, I am trying to sote pairs in a table as follows: #-- from elixir import * metadata.bind = sqlite:///:memory: metadata.bind.echo = False class Pairs(Entity): name = Field(String(50), primary_key = True)

[sqlalchemy] Re: Elixir question

2012-02-03 Thread lars van gemerden
I should probably make the pair method: def pair(name1, name2): p1, p2 = Pairs(name1), Pairs(name2) p1.other = p2 p2.other = p1 On Feb 3, 11:57 am, lars van gemerden l...@rational-it.com wrote: Hi, I am trying to sote pairs in a table as follows

[sqlalchemy] a more general elixir question

2012-02-03 Thread lars van gemerden
Is it possible to mix Elixir classes and SQLA classes in one database (with foreign keys between them)? Cheers, Lars -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe

[sqlalchemy] Re: a more general elixir question

2012-02-03 Thread lars van gemerden
objects mapped with SQLA On Feb 3, 12:13 pm, lars van gemerden l...@rational-it.com wrote: Is it possible to mix Elixir classes and SQLA classes in one database (with foreign keys between them)? Cheers, Lars -- You received this message because you are subscribed to the Google Groups

[sqlalchemy] Re: a more general elixir question

2012-02-03 Thread lars van gemerden
Too bad, thanks On Feb 3, 1:38 pm, erikj tw55...@gmail.com wrote: no, that's not possible Elixir does some custom postprocessing on a class definition, and so does Declarative, but they are not interoperatable On Feb 3, 1:20 pm, lars van gemerden l...@rational-it.com wrote: Thanks

Re: [sqlalchemy] Re: trouble with metaclass

2011-04-06 Thread lars van gemerden
On Mon, Apr 4, 2011 at 7:08 PM, Chris Withers ch...@simplistix.co.ukwrote: On 23/03/2011 09:14, lars van gemerden wrote: - I want to generate classes/tables based on metadata in another table in the database, filled by designers not programmers. Then you should be creating Tables

Re: [sqlalchemy] Re: trouble with metaclass

2011-03-23 Thread lars van gemerden
, Chris -- Simplistix - Content Management, Batch Processing Python Consulting - http://www.simplistix.co.uk -- Lars van Gemerden l...@rational-it.com +31 6 26 88 55 39 -- You received this message