[sqlalchemy] Re: sqlalchemy.orm.attributes.InstrumentedList
@svilen Thanks --~--~-~--~~~---~--~~ 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 from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: order_by
e.g. order_by = [desc(table1.mycol)] Disrupt07 napsal(a): In my table I have a column with type Boolean. When using order_by on this column I am getting the results as follows: False False True True True ... True I want them the other way round (the True first, then the False). How can I change the order? Thanks --~--~-~--~~~---~--~~ 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 from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: order_by
@ml Thanks --~--~-~--~~~---~--~~ 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 from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Stuck creating a custom relation using ActiveMapper
Hi, I'm trying to create a relation like this Testing [1] - [many] Target (where target.is_testtgt==0) i.e. I want to map only to Target rows that match the where condition. Now, this is easy enough using assign_mapper: assign_mapper(ctx, Testing, testing, properties={ 'targets': relation(Target, primaryjoin=((target.c.testingid==testing.c.id) (target.c.is_testtgt!= 1))) } ) However, I'm using ActiveMapper. I can't do the same, as the relation needs to use Testing.c.id, and at that point Testing isn't defined, causing this to error: target = one_to_many('Target', colname='testingid', backref='testing', primary_join=((Testing.c.id==Target.c.testingid) ( Target.c.is_testtgt != 1))) So, I thought I'd add the relation later on. Again, this is easy with assign_mapper: mp.properties['target'] = relation(Target, primaryjoin=((Target.c.testingid == Testing.c.id) (Target.c.is_testtgt!= 1)) ) And that works fine. I thought to do the equivalent with ActiveMapper: class_mapper(Testing).properties = {'target': relation(Target, primaryjoin=((Target.c.testingid == Testing.c.id) (Target.c.is_testtgt!= 1)) ) } But then Testing.get(1234).targets gives an AttributeError. So, is there any way to achieve this using ActiveMapper? Any help appreciated. Paul --~--~-~--~~~---~--~~ 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 from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] connecting to ODBC backed by MS-SQL?
Is there a simple example of how to connect to a SQL Server instance using SQLAlchemy and the adodbapi module? Searching in this group didn't seem to find any concrete examples of the connection string I need to connect to an ODBC datasource. vic --~--~-~--~~~---~--~~ 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 from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: connecting to ODBC backed by MS-SQL?
Ach my sqlserver instance seems to just take a long time and I'm too impatient. create_engine('mssql://localhost/some_db_name') takes 10 seconds for some reason, but it does work. weird. vic On Apr 16, 11:09 am, Victor Ng [EMAIL PROTECTED] wrote: Is there a simple example of how to connect to a SQL Server instance using SQLAlchemy and the adodbapi module? Searching in this group didn't seem to find any concrete examples of the connection string I need to connect to an ODBC datasource. vic --~--~-~--~~~---~--~~ 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 from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Stuck creating a custom relation using ActiveMapper
Hello, Paul Johnston a écrit : Hi, I'm trying to create a relation like this Testing [1] - [many] Target (where target.is_testtgt==0) i.e. I want to map only to Target rows that match the where condition. Now, this is easy enough using assign_mapper: assign_mapper(ctx, Testing, testing, properties={ 'targets': relation(Target, primaryjoin=((target.c.testingid==testing.c.id) (target.c.is_testtgt != 1))) } ) However, I'm using ActiveMapper. I can't do the same, as the relation needs to use Testing.c.id http://Testing.c.id, and at that point Testing isn't defined, causing this to error: target = one_to_many('Target', colname='testingid', backref='testing', primary_join=(( Testing.c.id==Target.c.testingid) (Target.c.is_testtgt != 1))) So, I thought I'd add the relation later on. Again, this is easy with assign_mapper: mp.properties['target'] = relation(Target, primaryjoin=((Target.c.testingid == Testing.c.id http://Testing.c.id) (Target.c.is_testtgt != 1)) ) And that works fine. I thought to do the equivalent with ActiveMapper: class_mapper(Testing).properties = {'target': relation(Target, primaryjoin=((Target.c.testingid == Testing.c.id http://Testing.c.id) (Target.c.is_testtgt != 1)) ) } Have you tried : Testing.mapper.add_property('target', relation(Target, primary)) (of course after having defined the Testing and Target classes...) But then Testing.get(1234).targets gives an AttributeError. So, is there any way to achieve this using ActiveMapper? Any help appreciated. Paul --~--~-~--~~~---~--~~ 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 from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: selecting from M:N via secondary table's column
On Apr 16, 2007, at 5:55 AM, ml wrote: Hi! Let's have: - users_table = Table(users, metadata, Column(id, Integer, primary_key=True), Column(user_name, String(16)) ) addresses_table = Table(addresses, metadata, Column(id, Integer, primary_key=True), Column(addr, String(100)) ) _ua = Table(_ua, metadata, Column(id_user, Integer, ForeignKey(users.id)), Column(id_addr, Integer, ForeignKey(addresses.id)) ) mapper(Address, addresses_table) mapper(User, users_table, properties = { addresses : relation(Address, cascade=all, delete-orphan, secondary=_ua, backref=backref(user)), } ) - How can I select user's addresses when I know only his id? And I don't want to select the user first. session.query(Address).join(user).select(User.c.id==the user id) --~--~-~--~~~---~--~~ 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 from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: selecting from M:N via secondary table's column
How can I select user's addresses when I know only his id? And I don't want to select the user first. session.query(Address).join(user).select(User.c.id==the user id) I was afraid of that :-) I hoped it can go in a cleaner way like join(Address.c.user) but giving the property as a string. --~--~-~--~~~---~--~~ 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 from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Stuck creating a custom relation using ActiveMapper
Hi, Have you tried : Testing.mapper.add_property('target', relation(Target, primary)) (of course after having defined the Testing and Target classes...) Works a treat! Thank-you, it's great to have this working :-) Paul --~--~-~--~~~---~--~~ 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 from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: connecting to ODBC backed by MS-SQL?
I'm getting some pretty strange behavior when connecting to SQL Server. My code is pretty straight forward, just create an engine, create metadata, introspect on a table... from sqlalchemy import * db = create_engine('mssql://./msdb') meta = BoundMetaData(db) tbl = Table('sysdtssteplog', meta, autoload=True) Those 4 lines yield an exceptoin o the last line: Strategy 4: Traceback:Traceback (most recent call last): File build\bdist.win32\egg\adodbapi\adodbapi.py, line 540, in executeHelper File COMObject ADODB.Command, line 3, in Execute File c:\python24\lib\site-packages\win32com\client\dynamic.py, line 258, in _ApplyTypes_ result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, retType, argTypes ) + args) com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft OLE DB Provider for SQL Server', 'Cannot create new connection because in manual or distributed transaction mode.', None, 0, -2147467259), None) --- ADODBAPI on command:SELECT [C].[COLUMN_NAME], [TABLE_CONSTRAIN_8109].[CONSTR AINT_TYPE] FROM [INFORMATION_SCHEMA].[KEY_COLUMN_USAGE] AS C, [INFORMATION_SCHEMA].[TABLE_C ONSTRAINTS] AS [TABLE_CONSTRAIN_8109] WHERE [TABLE_CONSTRAIN_8109].[CONSTRAINT_NAME] = [C].[CONSTRAINT_NAME] AND [C].[ TABLE_NAME] = ? with parameters: ['sysdtssteplog'] 'SELECT [C]. [COLUMN_NAME], [T ABLE_CONSTRAIN_8109].[CONSTRAINT_TYPE] \nFROM [INFORMATION_SCHEMA]. [KEY_COLUMN_U SAGE] AS C, [INFORMATION_SCHEMA].[TABLE_CONSTRAINTS] AS [TABLE_CONSTRAIN_8109] \ nWHERE [TABLE_CONSTRAIN_8109].[CONSTRAINT_NAME] = [C]. [CONSTRAINT_NAME] AND [C]. [TABLE_NAME] = ?' ['sysdtssteplog'] If I try to assign tbl one more time, I get no exception. Verry odd and I've had no luck debugging this in sqlalchemny. vic --~--~-~--~~~---~--~~ 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 from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: connecting to ODBC backed by MS-SQL?
Oops - fingers are faster than my brain. Here's the snippet from the second attempt at creating a Table using autoload, and it succeeds. --- In [10]: tbl = Table('sysdtssteplog', meta, autoload=True) In [11]: [c.name for c in tbl.columns] Out[11]: ['stepexecutionid', 'lineagefull', 'stepname', 'stepexecstatus', 'stepexecresult', 'starttime', 'endtime', 'elapsedtime', 'errorcode', 'errordescription', 'progresscount'] --~--~-~--~~~---~--~~ 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 from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: connecting to ODBC backed by MS-SQL?
It sounds like its getting to be time to make pyodbc the preferred DBAPI interface for MSSQL. I'll start a new thread to see if there's any objections. On 4/16/07, Victor Ng [EMAIL PROTECTED] wrote: Sweet! This seems to work well now. Is there a way I can update the documentation for the MS-SQL backend to suggest using the PyODBC drivers instead of the adodbapi and the pymssql drivers? Thanks again! vic --~--~-~--~~~---~--~~ 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 from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Proposal: Make pyodbc the preferred DB-API for MSSQL
Unless there's any objections, I think it's time to make pyodbc the preferred access method for MSSQL. Currently the MSSQL module checks for DBAPI interfaces in this order if one isn't specified explicitly: adodbapi pymssql pyodbc I'd like to change it to the exact opposite: pyodbc pymssql adodbapi Thanks once again to Paul Johnston for all his work getting pyodbc integrated, and getting a lot of MSSQL unit tests to pass. Rick --~--~-~--~~~---~--~~ 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 from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] create indexes on function
Is it possible to create indexes using a function using sqlalchemy and postgresql? Something like: create index idx on table (lower(table.field)) Thanks, Steve --~--~-~--~~~---~--~~ 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 from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Postgres user management and SQLAlchemy
I wondered if it was possible to manage users inside postgres with the help of SQLAlchemy. But I guess Postgres users are special objects and not just rows in a table. I tried to do this, but it did not work. from sqlalchemy import * metadata = BoundMetaData('postgres://127.0.0.1/template1') pg_authid = Table('pg_authid', metadata, autoload=True) pg_auth_members = Table('pg_auth_members', metadata, autoload=True) For some reason, I get a key error back. Would this be possible at all? Koen --~--~-~--~~~---~--~~ 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 from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: How to survive a database restart (firebird) ?
Thanks Michael, both the 2 approaches did the trick... :) On 4/16/07, Michael Bayer [EMAIL PROTECTED] wrote: with firebird, the appropriate database closed exceptions need to be added to its dialect's is_disconnect() method...someone needs to submit a patch for that (you can create one based on the exception youre getting, which would look like: def is_disconnect(self, e): if isinstance(e, self.dbapi.OperationalError): return 'Unable to complete network request to host' in str(e) ). I came to that function: def is_disconnect(self, e): if isinstance(e, self.dbapi.OperationalError): return 'Unable to complete network request to host' in str(e) and \ ('Error reading data from the connection' in str(e) or \ 'Error writing data to the connection' in str(e)) else: return False which is a little more specific than yours... Which one do you prefer ? Only evaluating Unable do complete network... is enough ? I don't have a decent diff/patch tool at my windows box, but I can send you a patch tonight (er... it is already night here). Thanks again... Roger --~--~-~--~~~---~--~~ 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 from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Postgres user management and SQLAlchemy
not sure what kind of key error youre getting back, but the issue probably relates either to the lack of a schema argument or improper permissions on one or both tables. On Apr 16, 2007, at 5:24 PM, Koen Bok wrote: I wondered if it was possible to manage users inside postgres with the help of SQLAlchemy. But I guess Postgres users are special objects and not just rows in a table. I tried to do this, but it did not work. from sqlalchemy import * metadata = BoundMetaData('postgres://127.0.0.1/template1') pg_authid = Table('pg_authid', metadata, autoload=True) pg_auth_members = Table('pg_auth_members', metadata, autoload=True) For some reason, I get a key error back. Would this be possible at all? Koen --~--~-~--~~~---~--~~ 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 from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---