[sqlalchemy] Re: sqlalchemy limit by clause

2007-04-16 Thread svilen
default of limit is None. All those query.select arguments go in a orm.query.QueryContext() do see its __init__ for which arg has what default. On Tuesday 17 April 2007 09:31:04 Disrupt07 wrote: > I am defining my result list the following way: > > result = queryobject.select(mytable.c.columnname

[sqlalchemy] sqlalchemy limit by clause

2007-04-16 Thread Disrupt07
I am defining my result list the following way: result = queryobject.select(mytable.c.columnname == columnname, limit = maxResults, offset = 0) maxResults is the number of records I want returned. In case I want all the records, I am setting maxResults as -1. However, this is not working for m

[sqlalchemy] Re: How to survive a database restart (firebird) ?

2007-04-16 Thread Roger Demetrescu
Michael, here it is... Patch attached . Cheers, Roger On 4/16/07, Roger Demetrescu <[EMAIL PROTECTED]> wrote: > Thanks Michael, both the 2 approaches did the trick... :) > > > On 4/16/07, Michael Bayer <[EMAIL PROTECTED]> wrote: > > > > with firebird, the appropriate "database closed" except

[sqlalchemy] Re: splitting a relation into multiple properties

2007-04-16 Thread Michael Bayer
On Apr 16, 2007, at 8:00 PM, jason kirtland wrote: > > Michael wrote: >> On Apr 12, 2007, at 2:03 PM, jason kirtland wrote: >>> [...] >>> This does work, but because relation updates are happening >>> outside of the InstrumentedList (i.e. not on 'analysis' >>> directly), I'm losing the events th

[sqlalchemy] Re: splitting a relation into multiple properties

2007-04-16 Thread jason kirtland
Michael wrote: > On Apr 12, 2007, at 2:03 PM, jason kirtland wrote: >> [...] >> This does work, but because relation updates are happening >> outside of the InstrumentedList (i.e. not on 'analysis' >> directly), I'm losing the events that would normally be >> triggered. I don't think I can manual

[sqlalchemy] Re: Postgres user management and SQLAlchemy

2007-04-16 Thread Michael Bayer
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

[sqlalchemy] Re: create indexes on function

2007-04-16 Thread Michael Bayer
not directly through constructed SQL expressions but easy enough to just execute the literal text --- connection.execute("create index idx on table (lower(table.field))") On Apr 16, 2007, at 4:40 PM, Steve Huffman wrote: > > Is it possible to create indexes using a function using sqlalchemy a

[sqlalchemy] Re: selecting from M:N via secondary table's column

2007-04-16 Thread ml
Michael Bayer napsal(a): > > On Apr 16, 2007, at 1:37 PM, ml wrote: > 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==) >>> >>> >> I was afraid of that :-) I hoped it

[sqlalchemy] Re: How to survive a database restart (firebird) ?

2007-04-16 Thread Roger Demetrescu
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 o

[sqlalchemy] Postgres user management and SQLAlchemy

2007-04-16 Thread Koen Bok
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

[sqlalchemy] create indexes on function

2007-04-16 Thread Steve Huffman
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 "sqla

[sqlalchemy] Re: How to survive a database restart (firebird) ?

2007-04-16 Thread Michael Bayer
theres no way to detect the database being restarted until a connection execute() is actually attempted, short of using a separate worker thread that is constantly polling the database (maybe that would make a good SA extension). so because we are storing connections in a connection pool, w

[sqlalchemy] How to survive a database restart (firebird) ?

2007-04-16 Thread Roger Demetrescu
Hi folks, I'm having some connection problems with a TG application using Firebird. To try understand the problems I did a test with Postgresql and Firebird: [Postgresql] 1) started the app. and browsed some pages 2) restarted postgresql 3) in the first refresh of the page, after the restart, I

[sqlalchemy] Proposal: Make pyodbc the preferred DB-API for MSSQL

2007-04-16 Thread Rick Morrison
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

[sqlalchemy] Re: connecting to ODBC backed by MS-SQL?

2007-04-16 Thread Rick Morrison
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

[sqlalchemy] Re: connecting to ODBC backed by MS-SQL?

2007-04-16 Thread Victor Ng
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 becau

[sqlalchemy] Re: connecting to ODBC backed by MS-SQL?

2007-04-16 Thread Paul Johnston
Hi, Have a go using pyodbc instead of adodbapi. An easy way to force SA to use pyodbc is to uninstall adodbapi (and pymssql if you have that installed). Paul Victor Ng wrote: >I'm getting some pretty strange behavior when connecting to SQL >Server. > >My code is pretty straight forward, jus

[sqlalchemy] Re: connecting to ODBC backed by MS-SQL?

2007-04-16 Thread Victor Ng
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

[sqlalchemy] Re: connecting to ODBC backed by MS-SQL?

2007-04-16 Thread Victor Ng
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,

[sqlalchemy] Re: Stuck creating a custom relation using ActiveMapper

2007-04-16 Thread Paul Johnston
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 rec

[sqlalchemy] Re: selecting from M:N via secondary table's column

2007-04-16 Thread Michael Bayer
On Apr 16, 2007, at 1:37 PM, ml wrote: > >>> >>> 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==) >> >> > > I was afraid of that :-) I hoped it can go in a cleaner way lik

[sqlalchemy] Re: PDF Documentation?

2007-04-16 Thread Nicolas Keller
I just uploaded a PDF Version of the current documentation to: http://groups.google.com/group/sqlalchemy/web/sqlalchemy_0_3_6.pdf I can't do this for every minor release but from time to time... :-) Have fun! On 15 Apr., 01:39, "gDog" <[EMAIL PROTECTED]> wrote: > Hello, all- > > I have just fi

[sqlalchemy] Re: selecting from M:N via secondary table's column

2007-04-16 Thread ml
>> >> 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==) > > 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 stri

[sqlalchemy] Re: selecting from M:N via secondary table's column

2007-04-16 Thread Michael Bayer
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,

[sqlalchemy] Re: Stuck creating a custom relation using ActiveMapper

2007-04-16 Thread remi jolin
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, Test

[sqlalchemy] Re: connecting to ODBC backed by MS-SQL?

2007-04-16 Thread Paul Johnston
Hi, Try mssql://./some_db_name instead, that certainly doesn't cause a 10s delay for me. Paul On 4/16/07, Victor Ng <[EMAIL PROTECTED]> wrote: > > > 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

[sqlalchemy] Re: connecting to ODBC backed by MS-SQL?

2007-04-16 Thread Victor Ng
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 c

[sqlalchemy] connecting to ODBC backed by MS-SQL?

2007-04-16 Thread Victor Ng
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 --~--~-~--~~~---~--

[sqlalchemy] Stuck creating a custom relation using ActiveMapper

2007-04-16 Thread Paul Johnston
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(Tar

[sqlalchemy] Re: order_by

2007-04-16 Thread Disrupt07
@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 mor

[sqlalchemy] Re: order_by

2007-04-16 Thread ml
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 F

[sqlalchemy] order_by

2007-04-16 Thread Disrupt07
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 --~--~-~--~~

[sqlalchemy] selecting from M:N via secondary table's column

2007-04-16 Thread ml
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 = Tab