[sqlalchemy] ...kill_hung_threads status...
Hi guys. I keep getting this message: [paste.httpserver.ThreadPool] kill_hung_threads status: 10 threads (1 working, 9 idle, 0 starting) ave time 0.03sec, max time 0.03sec, killed 0 workers Do I have to close a connection every time i'm querying the db? -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: double data insert in many-to-many relations
Okay, i have got a stupid question. i have got something like this: result = Session.query(Messages).filter( Messages.from_user == 1).filter( User.id != 1).all() This query is supposed to get all the messages ( Messages table) that have the senders id (from_user) but select ONLY this messages that are connected to all users except user with id = 1. This tables are many-to-many( Messages, Messages_Users, Users ). The relationship is set correctly. Is this even possible? ;-) -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] another many-to-many question
Hi. I'm quering many-to-many tables (ex. User, User_Car, Car), as a result i'm getting a data like this: result: + id + name + street + car - list of users Cars Is it possible, if yes then how, to filter this result to math this variables ex. user.id = 1 and car.id = 3? So i can get User object with User.car list contaning one Car object? -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] double data insert in many-to-many relations
Hi. I'm building a db with many-to-many relations, ex. * Table Users * Table Messages * Table Messages_Users when the users sends a message to other users i'm inserting that message to the db like so, *Messages - insert 1 row with the message, values ( title, text , date, etc... ) *Messages_Users - insert 2 rows ( one with connetion to the sending user and message,second with connection to the recieving user and message), values ( user_id, message_id, id_from, id_to, etc...) at the process of inserting the second row to the Messages_Users table i'm getting an error, ConcurrentModificationError: Updated rowcount 0 does not match number of objects updated 1 Mabey there's a better way to do this? Anyone have a clue? -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: double data insert in many-to-many relations
Hi. Okay, thanks ;-) This solution seems pretty good, but can i associate two records from MESSAGES_USERS_RECIEVING and MESSAGES_USERS_SENDING to one (the same) message record in messages table? If yes, then how? On 1 Wrz, 13:04, Francisco Souza franci...@franciscosouza.net wrote: On Wed, Sep 1, 2010 at 5:14 AM, Dobrysmak lukasz.szyman...@gmail.comwrote: [...] ConcurrentModificationError: Updated rowcount 0 does not match number of objects updated 1 Mabey there's a better way to do this? Anyone have a clue? Hi :) you should have to many-to-many relationships and two association tables: messages_users_receiving and messages_users_sending. So you configure two many to many relationships with different secondary tables. Cheers, Francisco Souza Software developer at Giran and also full time Open source evangelist at full time English:http://www.franciscosouza.net Portuguese:http://www.franciscosouza.com.br Twitter: @franciscosouza +55 27 3026 0264 On Wed, Sep 1, 2010 at 5:14 AM, Dobrysmak lukasz.szyman...@gmail.comwrote: Hi. I'm building a db with many-to-many relations, ex. * Table Users * Table Messages * Table Messages_Users when the users sends a message to other users i'm inserting that message to the db like so, *Messages - insert 1 row with the message, values ( title, text , date, etc... ) *Messages_Users - insert 2 rows ( one with connetion to the sending user and message,second with connection to the recieving user and message), values ( user_id, message_id, id_from, id_to, etc...) at the process of inserting the second row to the Messages_Users table i'm getting an error, ConcurrentModificationError: Updated rowcount 0 does not match number of objects updated 1 Mabey there's a better way to do this? Anyone have a clue? -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.comsqlalchemy%2bunsubscr...@googlegrou ps.com . For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: begginers query question
Hi. Thanks yor suggestions but it does not work for me. I'm guessing i'm doing something wrong. I've got this two classes (User , Groups) in seperet files, where i've got to put the relation (relationship)? in both files? or just the one with the ForeignKey? Also, is the relationship must be placed inside the class? On 24 Sie, 16:20, werner wbru...@free.fr wrote: On 24/08/2010 15:53, werner wrote: Hi, On 24/08/2010 10:14, Dobrysmak wrote: Hi guys. I've got a little problem with the sqlalchemy syntax. I've got two tables with relations: Table_Goups id int(4) PrimaryKey not null, name varchar(50) not null; and Table_User id int(4) Primary Key not null, login varchar(50) not null, id_group int(4) Foreign Key not null; i would like to build a query that would gets the user data from Table_User and the id_group but insted od showing the id_group number i want to show the Table_Groups.name Can anyone help? I use SA declarative, so you would define something like this in your model: class Group(Base): __table__ = sa.Table(u'groups', metadata, sa.Column(u'id', sa.Integer(), sa.Sequence('gen_contact_id'), primary_key=True, nullable=False), sa.Column(u'name', sa.String(length=70, convert_unicode=False), nullable=False), ) Oops, a copy/paste error, should be: sa.Sequence('gen_group_id') class User(Base): __table__ = sa.Table(u'users', metadata, sa.Column(u'id', sa.Integer(), sa.Sequence('gen_contact_id'), primary_key=True, nullable=False), and another one, a copy/paste error, should be: sa.Sequence('gen_user_id') sa.Column(u'name', sa.String(length=70, convert_unicode=False), nullable=False), sa.Column(u'fk_group', sa.Integer(), sa.ForeignKey(u'groups.id'), nullable=False), ) group = sao.relation('Group', backref='user') And then to query you could do e.g. this: for usr in session.query(db.User).all(): print 'user: %s, group name: %s' % (usr.name, usr.group.name) Check out the SA doc, especially the tutorials: http://www.sqlalchemy.org/docs/ormtutorial.html http://www.sqlalchemy.org/docs/ormtutorial.html#creating-table-class-... Hope this helps Werner -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] begginers query question
Hi guys. I've got a little problem with the sqlalchemy syntax. I've got two tables with relations: Table_Goups id int(4) PrimaryKey not null, name varchar(50) not null; and Table_User id int(4) Primary Key not null, login varchar(50) not null, id_group int(4) Foreign Key not null; i would like to build a query that would gets the user data from Table_User and the id_group but insted od showing the id_group number i want to show the Table_Groups.name Can anyone help? -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.