Re: [sqlalchemy] SAWarning: Unicode type received non-unicode bind param value

2015-04-22 Thread Sebastian Elsner | RISE
s.com>. To post to this group, send email to sqlalchemy@googlegroups.com <mailto:sqlalchemy@googlegroups.com>. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout. -- _*check out pointcloud9.com*_ <http://po

Re: [sqlalchemy] mysql double issue

2013-11-20 Thread Sebastian Elsner
nt Decimal objects back in this case with DOUBLE, I’d subclass mysql.DOUBLE and specify a new result_processor() method. On Nov 20, 2013, at 7:00 AM, Sebastian Elsner wrote: Hello, I am inserting float data into a MySQL column of type DOUBLE. The data gets inserted properly (verified

[sqlalchemy] mysql double issue

2013-11-20 Thread Sebastian Elsner
DOUBLE) engine = create_engine('mysql://user:pass@localhost/test', echo=True) Base.metadata.create_all(engine) s = sessionmaker(engine)() r = SomeClass(value=0.1234567891234567) s.add(r) s.commit() x = s.query(SomeClass).get(1) print x.value Regards Sebastian -- check out www.pointcloud9.com Se

Re: [sqlalchemy] newest address for each user

2013-10-21 Thread Sebastian Elsner
Addresses.address_id).\ > where(UserAddresses.user_id == id).\ > correlate_except(Address, UserAddresses) > ) > > On Oct 21, 2013, at 3:12 AM, Sebastian Elsner wrote: > >> Thank you for the help! Additionally, I was wondering if it would be >> able to make "newe

Re: [sqlalchemy] newest address for each user

2013-10-21 Thread Sebastian Elsner
l Bayer: > On Oct 19, 2013, at 4:24 PM, Sebastian Elsner wrote: > >> Hello, >> >> using the Address and User example, where the Address is connected to >> the User via a many-to-many relationship, I want to get all users with >> the date of their newest

[sqlalchemy] newest address for each user

2013-10-19 Thread Sebastian Elsner
Hello, using the Address and User example, where the Address is connected to the User via a many-to-many relationship, I want to get all users with the date of their newest address. This is what I have now: s.query(User, s.query(func.max(Address.created)).\ filter(Address.users.any()).correlate(U

Re: [sqlalchemy] update with custom Type

2013-08-29 Thread Sebastian Elsner
ay :) On 08/28/2013 08:08 PM, Michael Bayer wrote: On Aug 28, 2013, at 9:59 AM, Sebastian Elsner wrote: Now I would like to be able to do the following: s.query(Foo).update({"some_timecode": Foo.some_timecode.add_hours(5)}) # Adds 5 hours to every Foo's timecode I have s

[sqlalchemy] update with custom Type

2013-08-28 Thread Sebastian Elsner
ry(Foo).update({"some_timecode": Foo.some_timecode + TC("01:00:00:00:00")}) I have tried implementing the __add__ for both the TC and Timecode class and read the "Augmenting Existing Types" help, but failed to put the puzzle together. Thank you for helping! S

Re: [sqlalchemy] Do not add entities automatically to the session?

2013-07-22 Thread Sebastian Elsner
gle Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. Fo

Re: [sqlalchemy] count subquery

2013-06-24 Thread Sebastian Elsner
o make the select() and then call as_scalar() on it so that it behaves like a column in a SQL expression. On Jun 24, 2013, at 9:34 AM, Sebastian Elsner wrote: Hello, I am trying to translate this SQL to a SQLAlchemy query, but failed so far: select `users`.`name`, `assignments`.`id`, ( se

[sqlalchemy] count subquery

2013-06-24 Thread Sebastian Elsner
Hello, I am trying to translate this SQL to a SQLAlchemy query, but failed so far: select `users`.`name`, `assignments`.`id`, ( select count(*) from `assignments` where `assignments`.`user_id` = `users`.`id` ) as `num_assignments` from `users` join `assignments` on `assignm

Re: [sqlalchemy] query.whereclause

2013-02-28 Thread Sebastian Elsner
Thank you, this did the trick. And since only I use it offline the security issues are OK for me. On 02/28/2013 12:27 PM, Simon King wrote: On Thu, Feb 28, 2013 at 10:28 AM, Sebastian Elsner wrote: Hello, I want to feed a Query.whereclause to mysqldump. For this i will need the full where

[sqlalchemy] query.whereclause

2013-02-28 Thread Sebastian Elsner
Hello, I want to feed a Query.whereclause to mysqldump. For this i will need the full where clause with all labels replaced with values, right now I get labels like :project_id_1. How can I do that? Many thanks, Sebastian -- check out www.pointcloud9.com Sebastian Elsner - Pipeline

[sqlalchemy] serialize list

2011-09-02 Thread Sebastian Elsner
Hello, I want to serialize a python list, which by convention can only contain strings and save it to mysql database in on column. I was thinking about an unicode column and an attribute event which just does a str(list) for saving and a eval(string) for access. I am not sure though if this i

Re: [sqlalchemy] Read-Only Database

2011-06-21 Thread Sebastian Elsner
-only, and would that simplify the work that SA does behind the scenes? Thanks, Mark -- Sebastian Elsner - Pipeline TD - r i s e | fx t: +49 30 201 803 00 sebast...@risefx.com c: +49 175 336 5739 7548 www.risefx.com r i s e | fx GmbH Schlesische Strasse 28, Aufgang B 10997 Berlin Richard-Byrd

[sqlalchemy] get_history not returning as expected

2011-06-07 Thread Sebastian Elsner
Hello, using Python 2.6 and SA 0.6.6. Please see the example below. I want to get the History of a relationship attribute, but whatever I pass to the "passive" argument, I never get the "deleted version" of the object, only the PASSIVE_NO_RESULT symbol (if I understand correctly, I would not

[sqlalchemy] logging user changes

2011-06-01 Thread Sebastian Elsner
nstances of multiple types. Is that possible? Can you give me a hint where to read up? Being in the design phase I am also open to other approaches on how to tackle logging of user changes in a db. Thanks Sebastian -- Sebastian Elsner - Pipeline TD - r i s e | fx t: +49 30 201 803 00 sebast.

Re: [sqlalchemy] understanding connection pooling

2011-03-18 Thread Sebastian Elsner
So, using MySQL with max_connections = 100 I quickly run out of connections, because every client is using about 6 connections, one for each dialog window, which has its own session instance. seems like an architecture that could use some trimming Yes, you are probably right. But what

[sqlalchemy] understanding connection pooling

2011-03-18 Thread Sebastian Elsner
Hello, I wanted to make sure, I get this right: every session creates its own connection on demand (only if I actually do query with the session), right? So, using MySQL with max_connections = 100 I quickly run out of connections, because every client is using about 6 connections, one for each

[sqlalchemy] self_group on Query

2010-10-15 Thread Sebastian Elsner
Hello, wanting to create the following query: (SELECT * from tbl ORDER BY b LIMIT 5) UNION ALL (SELECT * from tbl ORDER BY a LIMIT 5) The important thing are the (), which I cant get to work with the examples in the union() docs . I came across a solution involving self_group on Queries in

Re: [sqlalchemy] Newest records per category

2010-10-11 Thread Sebastian Elsner
, at 7:50 AM, Sebastian Elsner wrote: have one table called 'Assets' with a 'category' (String) and 'created' (DateTime) column. Now I would like to find the records created since a given datetime for each category: This is what I thought would work (with a self-joi

[sqlalchemy] Newest records per category

2010-10-11 Thread Sebastian Elsner
Hello, I have one table called 'Assets' with a 'category' (String) and 'created' (DateTime) column. Now I would like to find the records created since a given datetime for each category: This is what I thought would work (with a self-join): session.query(Asset).join(Asset, and_(Asset.catego

Re: [sqlalchemy] modify existing query with group_by and count

2010-06-28 Thread Sebastian Elsner
Thank you very much, from_self() works a treat! On 06/28/2010 04:47 PM, Michael Bayer wrote: On Jun 28, 2010, at 5:23 AM, Sebastian Elsner wrote: Hello, I build a query to filter a table depending on options a user can specify. So I have a working query to execute when all GUI elements

[sqlalchemy] modify existing query with group_by and count

2010-06-28 Thread Sebastian Elsner
Hello, I build a query to filter a table depending on options a user can specify. So I have a working query to execute when all GUI elements (which provide the filter information) are evaluated. What I do is asking for the GUI elements value and depending on that I modify the query: class Pr

[sqlalchemy] deleting

2010-04-14 Thread Sebastian Elsner
Hello, I am unsure on how to delete correctly. Lets say I have a query's result, which is a list. del list[5] does not seem to do anything, right? I would always have to do session.delete(list[5])? But what about when I created a mapped object, which is not yet persistent, how would I del

Re: [sqlalchemy] 'NoneType' object has no attribute '_sa_iterator' exception

2010-03-27 Thread Sebastian Elsner
-py2.5-linux-x86_64.egg/sqlalchemy/orm/collections.py", line 570, in __iter__ return iter(getattr(self._data(), '_sa_iterator')()) AttributeError: 'NoneType' object has no attribute '_sa_iterator' I don't have a good test for this, but i'm trying to create one

Re: [sqlalchemy] implications of weak_identity_map

2010-03-25 Thread Sebastian Elsner
would never have thought I would say this, but now I'd like to go back to c++ :) I am already using the newest build of PyQt, so I guess I will post on the mailing list there. Thank you, Sebastian On Wed, 24 Mar 2010 21:06:10 +0100, Michael Bayer wrote: Sebastian Elsner wrote: My

Re: [sqlalchemy] implications of weak_identity_map

2010-03-24 Thread Sebastian Elsner
My first question is: What exactly is the commit doing to the list returned from the query so that pointers to other objects are "lost" (python.exe will crash on me then)? The commit expires all attributes by default, since the transaction is committed, and upon next access will be loaded again

[sqlalchemy] implications of weak_identity_map

2010-03-24 Thread Sebastian Elsner
Hello, This is the situation: I am using Qt with its tree view to display data coming from sqlalchemy. Mapped classes are used as nodes for the tree. Relations define the connections to children and parent. As for the QTreeViews model data structure a sqlalchemy list returned by a query is

Re: [sqlalchemy] distinct query

2010-03-19 Thread Sebastian Elsner
Hello, qry = session.query(AssetCategory).join(Asset).join(Shot).filter(Shot.id==1).distinct() this one already did the trick. qry = qry.filter(Shot.id==shot_id_of_interest) what did you add this for? The results seem to be identical... that generates SELECT DISTINCT "AssetCategory".id

[sqlalchemy] distinct query

2010-03-18 Thread Sebastian Elsner
Hello, I am stuck here with a query, it't not too complicated I think, but I dont get it... I have three Class/table mappings: Shots, Assets, which belong to a Shot (1:n) and AssetCategories, which are owned by Assets (n:1) The objective is: For a given shot instance get all distinct Asset

Re: [sqlalchemy] three primary keys on association object

2010-03-05 Thread Sebastian Elsner
Oh, thanks for the pointer. There's so much to read and learn being new to SQLAlchemy... Sorry for bugging. On Fri, 05 Mar 2010 15:49:03 +0100, Michael Bayer wrote: Sebastian Elsner wrote: Hello, I have an association object declaratively with three primary keys, but on insert

[sqlalchemy] three primary keys on association object

2010-03-05 Thread Sebastian Elsner
Hello, I have an association object declaratively with three primary keys, but on insert, the first (id) is not autoincremented. Please see test the code below from sqlalchemy import create_engine, Column,Integer, String, ForeignKey from sqlalchemy.ext.declarative import declarative_base