Re: [sqlalchemy] TypeError: unsupported operand type(s) for -: 'float' and 'datetime.datetime' when subtracting DateTime columns directly with MySQL database

2013-06-29 Thread Charlie Clark
MySQL function timediff might be appropriate: http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_timediff Charlie -- Charlie Clark Managing Director Clark Consulting & Research German Office Kronenstr. 27a Düsseldorf D- 40217 Tel: +49-211-600-3657 Mobile: +49-178-782-6226 -

Re: [sqlalchemy] between .one() and .first()

2013-06-17 Thread Charlie Clark
ct, I have the query wrong and so want an exception. .count() would seem to be your friend here, at least in case that a lot of rows might be returned. Is there something already available that meets this need? Only if you can express that need as a query. Charlie -- Charlie Clark Managin

Re: [sqlalchemy] Feature suggestion: fake ForeignKeyConstraints to simplify joins

2013-06-13 Thread Charlie Clark
e unpredictable. The MySQL vs PostgreSQL holy war is completely irrelevant to this issue Indeed, but you started it! ;-) Charlie -- Charlie Clark Managing Director Clark Consulting & Research German Office Kronenstr. 27a Düsseldorf D- 40217 Tel: +49-211-600-3657 Mobile: +49-178-782-6226 -- You

Re: [sqlalchemy] Feature suggestion: fake ForeignKeyConstraints to simplify joins

2013-06-13 Thread Charlie Clark
recommend Postgres over MySQL but I don't see what the choice of backend has to do with this problem, except how well reflection works with Postgres. From a developer's perspective MySQL's biggest problem, apart from MyASM, is that its behaviour can be unpredictable. Charlie

Re: [sqlalchemy] Feature suggestion: fake ForeignKeyConstraints to simplify joins

2013-06-12 Thread Charlie Clark
Also, SERIAL? You must be using a real database engine. Well, er, yes. When it comes to modelling that's where you should start. And Oracle is making progress with MySQL now that InnoDB with separate files pro table and 5.6 even seems to have some kind of vacuuming built-in. Charlie -- Ch

Re: [sqlalchemy] Using SQL Expressions with existing declarative_base tables

2013-06-10 Thread Charlie Clark
Am 10.06.2013, 18:54 Uhr, schrieb Michael Bayer : Page.__table__.update() Duh! Just didn't see that. or agnostic of declarative: from sqlalchemy import inspect pages = inspect(Page).local_table pages.update() That looks nicer to me, thanks. Charlie -- Charlie Clark Managing Dir

Re: [sqlalchemy] Using SQL Expressions with existing declarative_base tables

2013-06-10 Thread Charlie Clark
te 'update'" How should I be doing this instead? Charlie -- Charlie Clark Managing Director Clark Consulting & Research German Office Kronenstr. 27a Düsseldorf D- 40217 Tel: +49-211-600-3657 Mobile: +49-178-782-6226 -- You received this message because you are subscribed to the Google

[sqlalchemy] Using SQL Expressions with existing declarative_base tables

2013-06-10 Thread Charlie Clark
so that I have access to .insert(), .update() for my models? Chrlie -- Charlie Clark Managing Director Clark Consulting & Research German Office Kronenstr. 27a Düsseldorf D- 40217 Tel: +49-211-600-3657 Mobile: +49-178-782-6226 -- You received this message because you are subscribed to the

Re: [sqlalchemy] Non negative integer column

2013-06-10 Thread Charlie Clark
written an interesting checker for Python 3 http://code.activestate.com/recipes/578528-type-checking-using-python-3x-annotations/ Charlie -- Charlie Clark Managing Director Clark Consulting & Research German Office Kronenstr. 27a Düsseldorf D- 40217 Tel: +49-211-600-3657 Mobile: +49-178-782-

Re: [sqlalchemy] Feature suggestion: fake ForeignKeyConstraints to simplify joins

2013-06-07 Thread Charlie Clark
ly dense and missing something obvious. Charlie -- Charlie Clark Managing Director Clark Consulting & Research German Office Kronenstr. 27a Düsseldorf D- 40217 Tel: +49-211-600-3657 Mobile: +49-178-782-6226 -- You received this message because you are subscribed to the Google Groups "sqla

Re: [sqlalchemy] Feature suggestion: fake ForeignKeyConstraints to simplify joins

2013-06-07 Thread Charlie Clark
a sub-class of groups. Am I missing something big in the original question as to why this isn't a reasonable solution? Charlie -- Charlie Clark Managing Director Clark Consulting & Research German Office Kronenstr. 27a Düsseldorf D- 40217 Tel: +49-211-600-3657 Mobile: +49-178

Re: [sqlalchemy] Feature suggestion: fake ForeignKeyConstraints to simplify joins

2013-06-06 Thread Charlie Clark
Am 06.06.2013, 23:36 Uhr, schrieb Michael Bayer : On Jun 6, 2013, at 5:18 PM, Charlie Clark wrote: Am 06.06.2013, 20:21 Uhr, schrieb Andy : IOW I have things and groups. The rel table is a many-to-many relation between things and groups. A thing also may have a favorite group; if

Re: [sqlalchemy] Feature suggestion: fake ForeignKeyConstraints to simplify joins

2013-06-06 Thread Charlie Clark
normalise to Favourites with strict 1:1 with things and groups? Charlie -- Charlie Clark Managing Director Clark Consulting & Research German Office Kronenstr. 27a Düsseldorf D- 40217 Tel: +49-211-600-3657 Mobile: +49-178-782-6226 -- You received this message because you are subscribed to

Re: [sqlalchemy] [Q][0.7.9] problem with with_entities(), over() and label()

2013-06-06 Thread Charlie Clark
th Python seems a weird way of striding through the results but maybe that's just SQL. Charlie -- Charlie Clark Managing Director Clark Consulting & Research German Office Kronenstr. 27a Düsseldorf D- 40217 Tel: +49-211-600-3657 Mobile: +49-178-782-6226 -- You received this message b

Re: [sqlalchemy] [Q][0.7.9] problem with with_entities(), over() and label()

2013-06-06 Thread Charlie Clark
functions. You can either try wrapping the SELECT in correlated subquery as the example shows or simply use HAVING rownum % 2 = 1 (I think this is best approach but I'm far from an expert). Try the SQL directly in the DB to see which works. Charlie -- Charlie Clark Managing Director

Re: [sqlalchemy] Including counts in query results

2013-06-05 Thread Charlie Clark
up.buildingCode = restroom.buildingCode) AS rr from user join userGroup on user.userGroupId = userGroup.userGroupId Charlie -- Charlie Clark Managing Director Clark Consulting & Research German Office Kronenstr. 27a Düsseldorf D- 40217 Tel: +49-211-600-3657 Mobile: +49-178-782-6226 -- You received t

Re: [sqlalchemy] DISTINCT with LIMIT problem

2013-05-31 Thread Charlie Clark
avoid this with a join between your tables? Charlie -- Charlie Clark Managing Director Clark Consulting & Research German Office Kronenstr. 27a Düsseldorf D- 40217 Tel: +49-211-600-3657 Mobile: +49-178-782-6226 -- You received this message because you are subscribed to the Google Groups &quo

Re: [sqlalchemy] non foreign-key relationship between schemas

2013-05-24 Thread Charlie Clark
e the relationship explicit, note dump, truncate, alter, import is often the only way to do this and enjoy the, er, show. Charlie -- Charlie Clark Managing Director Clark Consulting & Research German Office Kronenstr. 27a Düsseldorf D- 40217 Tel: +49-211-600-3657 Mobile: +49-178-782-6226

Re: [sqlalchemy] Can SQLAlchemy execute multiple select statements in a single round trip?

2013-05-24 Thread Charlie Clark
the database, SQLAlchemy gives you the flexibility to decide how you want your queries processed. With a persistent connection I wouldn't have thought it made much difference where the servers are. Charlie -- Charlie Clark Managing Director Clark Consulting & Research German Office

Re: [sqlalchemy] Can SQLAlchemy execute multiple select statements in a single round trip?

2013-05-23 Thread Charlie Clark
the mxODBC documentation which provides detailed information for the most common backends and a unified Python interface to them. http://www.egenix.com/products/python/mxODBC/doc/ Charlie -- Charlie Clark Managing Director Clark Consulting & Research German Office Kronenstr. 27a Düsseldorf D- 4021

Re: [sqlalchemy] Are consecutive query.get calls supposed to send a single SELECT query?

2013-05-21 Thread Charlie Clark
8) session.query(Descriptiontype).get(-2147483648) session.query(Descriptiontype).get(-2147483648) Each call to session.query() is creating a new query object, thus, a new query will run on the DB. Try: q = session.query(Descriptiontype) q.get(-24…) Charlie -- Charlie Clark Managing Direc

Re: [sqlalchemy] Working with stored procedures

2013-05-21 Thread Charlie Clark
r "table functions" like Postgres http://www.postgresql.org/docs/9.1/static/tablefunc.html ie. a view on a normalised table which transposes rows into columns, the dynamic nature of which causes I problems for the ORM, I think. Charlie -- Charlie Clark Managing Director Clark Consulting &a

Re: [sqlalchemy] Working with stored procedures

2013-05-19 Thread Charlie Clark
mmend completely bypassing SQLa for this sort of thing? I found I was doing that anyway because of the inability to map the results to any models. Charlie -- Charlie Clark Managing Director Clark Consulting & Research German Office Kronenstr. 27a Düsseldorf D- 40217 Tel: +49-211-600-3657 Mobile

[sqlalchemy] Working with stored procedures

2013-05-19 Thread Charlie Clark
Hi, I have created a stored procedure on a MySQL database to create a "pivot table". To reduce network traffic the procedure generates some SQL and then executes a statement. It has no return value. I have had trouble calling the procedure from sqlachemy using the mysq-connector driver. From th