[sqlalchemy] Re: count function problem

2007-03-15 Thread jose
Glauco wrote: Michael Bayer ha scritto: On Mar 14, 2007, at 12:49 PM, Glauco wrote: This is perfect but when i try to use count function the SQL composer try to do an expensive sql. In [63]: print select([tbl['azienda'].c.id], tbl['azienda']).count() *SELECT count(id) AS

[sqlalchemy] SQLite driver and space in the TypeEgine.get_col_spec

2007-03-15 Thread Manlio Perillo
Hi. After this thread: http://lists.initd.org/pipermail/pysqlite/2007-March/000994.html I think that the get_col_spec method for SLNumeric, SLString and SLChar should add a space after the type name, since pySQLite uses the first string for its type registry. However I'm not sure this is a

[sqlalchemy] how to sum path in a tree?

2007-03-15 Thread svilen
There is some graph - represented as edges in some assoc.table, and they having some associated item with them (e.g. weight or length). Is it possible to calculate the overall lenght of path from node to node (if there is a path at all) in SQL? Finding if there is a path in the graph from

[sqlalchemy] Re: pyodbc and tables with triggers

2007-03-15 Thread Rick Morrison
Sorry, Stephen, I replied too early; your second email arrived before the first. A whole day before the first. So until we get a real cleanup, you're looking to try modules in this order: ['pyodbc', 'adodbapi', 'pymssql'] Sounds OK to me -- any objections out there? Rick On 3/14/07, Rick

[sqlalchemy] Re: count function problem

2007-03-15 Thread Michael Bayer
On Mar 15, 2007, at 5:09 AM, Glauco wrote: because i expect that engine do a SELECT COUNT FROM BLABLA and no a SELECT COUNT FROM ( SELECT BLABLA) i think this is expensive for my DataBase. its not. optimizers can usually figure things like that out. I've done a lot of try this

[sqlalchemy] Re: SQLAlchemy test suite - no success/failure exit code

2007-03-15 Thread Michael Bayer
there is a sys.exit() that I added at Grig's request at the end of testbase.py; its testbase.py's main() method that runs the actual tests in all cases. the result code is determined by unittest's result.wasSuccessful(). it was working when i first implemented it, maybe you can help

[sqlalchemy] Re: SQLite driver and space in the TypeEgine.get_col_spec

2007-03-15 Thread Michael Bayer
read the thread, no idea what a space has to do with anything. can you be more specific. On Mar 15, 2007, at 8:37 AM, Manlio Perillo wrote: Hi. After this thread: http://lists.initd.org/pipermail/pysqlite/2007-March/000994.html I think that the get_col_spec method for SLNumeric,

[sqlalchemy] statement

2007-03-15 Thread Julien Cigar
Hello list, Any idea how I could generate this SQL statement under SQLAlchemy (especially the PostreSQL ARRAY clause ...) ? SELECT i.id, t.name AS taxo, i.geographic_range, ARRAY( (SELECT h.name FROM habitats h, invasive_habitats ih WHERE

[sqlalchemy] Re: how to sum path in a tree?

2007-03-15 Thread Michael Bayer
i think this kind of thing is more suited to the nested sets model for trees. a google will show you a million hits, heres one: http://dev.mysql.com/tech-resources/articles/hierarchical-data.html im not a fan of nested sets because theres a huge overhead to changing nodes (requires updates

[sqlalchemy] Re: SQLite driver and space in the TypeEgine.get_col_spec

2007-03-15 Thread Manlio Perillo
Michael Bayer ha scritto: read the thread, no idea what a space has to do with anything. can you be more specific. pySQLite read the first word of the column spec to find the converter. Here is a full example: import decimal from pysqlite2 import dbapi2 as sqlite from sqlalchemy import

[sqlalchemy] Re: how to sum path in a tree?

2007-03-15 Thread svilen
i think this kind of thing is more suited to the nested sets model for trees. a google will show you a million hits, heres one: http://dev.mysql.com/tech-resources/articles/hierarchical-data.html ahha. thanks. So this is to look/represent/store different part of the thing; in my case i need

[sqlalchemy] Re: statement

2007-03-15 Thread Michael Bayer
use literal text (since its PG only anyway), or use func.ARRAY(). On Mar 15, 2007, at 11:16 AM, Julien Cigar wrote: Hello list, Any idea how I could generate this SQL statement under SQLAlchemy (especially the PostreSQL ARRAY clause ...) ? SELECT i.id, t.name AS taxo,

[sqlalchemy] Re: SQLite driver and space in the TypeEgine.get_col_spec

2007-03-15 Thread Michael Bayer
the docs say register_converter is for custom types. seems like kind of a hack here ? why not make your own type ? On Mar 15, 2007, at 11:22 AM, Manlio Perillo wrote: Michael Bayer ha scritto: read the thread, no idea what a space has to do with anything. can you be more specific.

[sqlalchemy] Making msg board

2007-03-15 Thread tml
Hi, I doing a msg board with nested sets as descrived on http://dev.mysql.com/tech-resources/articles/hierarchical-data.html I'm not sure how to do a statement like this in sqlalchemy: SELECT node.id, node.topic, node.content FROM nested_category AS node, nested_category AS parent WHERE

[sqlalchemy] Re: Making msg board

2007-03-15 Thread svilen
use table.alias() for one of the roles - or for both. Hi, I doing a msg board with nested sets as descrived on http://dev.mysql.com/tech-resources/articles/hierarchical-data.html I'm not sure how to do a statement like this in sqlalchemy: SELECT node.id, node.topic, node.content FROM

[sqlalchemy] Re: SQLAlchemy test suite - no success/failure exit code

2007-03-15 Thread Michael Bayer
OK this was something small, the alltests.py scripts needed to call testbase's main() function and not its runTests() method, so that the exit code is propigated. rev 2414. On Mar 14, 2007, at 10:30 PM, [EMAIL PROTECTED] wrote: Some of you may know that I run a Python buildbot for

[sqlalchemy] Best practices for database connection errors

2007-03-15 Thread vinjvinj
Hi, In my application I'm working with three different databases. Case 1: For 2 databases I'm using the connection object directly execute sql and Case 2: In the 3rd database I'm using the statement object and then doing the statement.execute, where the db is implicitly associated with the

[sqlalchemy] Re: Making msg board

2007-03-15 Thread Ram
Hi, that worked great! thanks :) - tml On Mar 15, 9:10 am, svilen [EMAIL PROTECTED] wrote: use table.alias() for one of the roles - or for both. Hi, I doing a msg board with nested sets as descrived on http://dev.mysql.com/tech-resources/articles/hierarchical-data.html I'm not sure

[sqlalchemy] Re: SQLite driver and space in the TypeEgine.get_col_spec

2007-03-15 Thread Manlio Perillo
Michael Bayer ha scritto: the docs say register_converter is for custom types. seems like kind of a hack here ? As I can see, it is not an hack. why not make your own type ? I have tried to replace 'NUMERIC' with 'DECIMAL' or 'XDECIMAL'; the result is the same: pysqlite converts the

[sqlalchemy] table name bind param

2007-03-15 Thread tml
t = metadata.engine.text(LOCK TABLE :table_name WRITE; , bindparams=[bindparam('table_name', type=types.String)]) will not work as the generated statement looks like: LOCK TABLE 'my_table_name' WRITE; Is there any other type I can specify which doesn't quote the string for tablename? The table

[sqlalchemy] Re: Making msg board

2007-03-15 Thread tml
Hi svilen, thanks. I have that query working now. On Mar 15, 9:10 am, svilen [EMAIL PROTECTED] wrote: use table.alias() for one of the roles - or for both. Hi, I doing a msg board with nested sets as descrived on http://dev.mysql.com/tech-resources/articles/hierarchical-data.html I'm

[sqlalchemy] Re: table name bind param

2007-03-15 Thread tml
also to clarify, the text actually has :table_name used in many other places: t = metadata.engine.text(LOCK TABLE :table_name WRITE; UPDATE :table_name SET rgt=rgt + 2 WHERE rgt :insert_node_val and parent_id = :parent_id; UPDATE

[sqlalchemy] reflection of unicode columns

2007-03-15 Thread dvd
Hi all, I'm working with postgres and sqlalchemy, I found a strange behavior (a bug?) of the reflection code, take a look at this: # import sqlalchemy as sa engine = sa.create_engine('postgres://xxx:[EMAIL PROTECTED]/xxx') metadata =

[sqlalchemy] Re: table name bind param

2007-03-15 Thread King Simon-NFHD78
tml wrote: also to clarify, the text actually has :table_name used in many other places: t = metadata.engine.text(LOCK TABLE :table_name WRITE; UPDATE :table_name SET rgt=rgt + 2 WHERE rgt :insert_node_val and parent_id = :parent_id;

[sqlalchemy] Re: statement

2007-03-15 Thread Michael Bayer
On Mar 15, 2007, at 12:23 PM, Julien Cigar wrote: it returns something like: (u'freshwater', 33, 1983, u'Vascular plants', u'Lemna minuta', u'Minute duckweed') (u'terrestial', 39, 2006, u'Vascular plants', u'Lysichiton americanus', u'American skunk cabbage') (u'freshwater', 39,

[sqlalchemy] Re: Best practices for database connection errors

2007-03-15 Thread Michael Bayer
On Mar 15, 2007, at 12:19 PM, vinjvinj wrote: cases above. Ideally you would want the database layer to recreate the connection and then try to execute the statement again. whys that ? what if you just have the wrong connection string, or the database is stopped ? do you expect the

[sqlalchemy] Re: reflection of unicode columns

2007-03-15 Thread Michael Bayer
postgres doesnt have a unicode column type. the Unicode SA type is a string type with additional python-side processing of the data. to reflect a table with some columns coming back as Unicode, see the metadata docs on overriding columns. also you might want to forego the Unicode type

[sqlalchemy] Re: SQLite driver and space in the TypeEgine.get_col_spec

2007-03-15 Thread Michael Bayer
if a space in the DDL for a create table is actually significant to SQLite, then im not sure if i want to build that into the core. also im not even sure what you really want, is it this? NUMERIC (19,5) anyway, i still dont understand why you dont make your own type. by which I mean:

[sqlalchemy] Re: Best practices for database connection errors

2007-03-15 Thread vinjvinj
throw consistent errors at consistent points of execution. if you think your database was stopped and is now re-started, you can call invalidate() on an individual connection and then close() it for it to be replaced in the pool, or more likely you can call dispose() on your engine and it

[sqlalchemy] Re: SQLAlchemy test suite - no success/failure exit code

2007-03-15 Thread skip . montanaro
Michael OK this was something small, the alltests.py scripts needed Michael to call testbase's main() function and not its runTests() Michael method, so that the exit code is propigated. rev 2414. Excellent. Trying a test run now... Skip

[sqlalchemy] Re: Best practices for database connection errors

2007-03-15 Thread Michael Bayer
Id say you have to monkeypatch Connection._execute_raw() with a wrapping method for now (or dialect.do_execute()/do_execute_many ()).I have observed that execute() is not the only place you might get an exception. sometimes you get it when calling cursor() (we do catch those and

[sqlalchemy] Re: don't automatically stringify compiled statements - patch to base.py

2007-03-15 Thread Monty Taylor
On 3/15/07, Michael Bayer [EMAIL PROTECTED] wrote: well at least make a full blown patch that doesnt break all the other DB's. notice that an Engine doesnt just execute Compiled objects, it can execute straight strings as well. thats why the dialect's do_execute() and do_executemany() take

[sqlalchemy] Examples of joins between three or more tables?

2007-03-15 Thread Gloria
Hi All, Good examples of rudimentary joins of 3 or more tables are hard to find. Please point me to some decent examples. Thank you, ~G~ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to

[sqlalchemy] Re: don't automatically stringify compiled statements - patch to base.py

2007-03-15 Thread Monty Taylor
YES. This is good stuff. Thanks again. On 3/16/07, Monty Taylor [EMAIL PROTECTED] wrote: On 3/15/07, Michael Bayer [EMAIL PROTECTED] wrote: well at least make a full blown patch that doesnt break all the other DB's. notice that an Engine doesnt just execute Compiled objects, it can

[sqlalchemy] Re: Examples of joins between three or more tables?

2007-03-15 Thread Michael Bayer
a SQL statement containing joins usually has the joins in a chain: select * from table1 JOIN table2 ON table1.somecolumn = table2.somecolumn JOIN table3 on table2.somecolumn=table3.somecolumn ... SQLAlchemy's join function works in a similar way. you can keep calling join on the previous