[sqlalchemy] Re: Get the row count from a query

2022-06-06 Thread Jason Hoppes
Thank you Sergey. On Saturday, June 4, 2022 at 7:08:25 AM UTC-4 Sergey V. wrote: > An alternative would be > > session.query(User).filter(User.id_ == id).count() > > On Saturday, June 4, 2022 at 4:45:49 AM UTC+10 jason@stormfish-sci.com > wrote: > >> I believe

[sqlalchemy] Re: Get the row count from a query

2022-06-03 Thread Jason Hoppes
I believe I finally found a solution: select(func.count(User.id_)).where(User.id_ == id) Thank you for taking the time to look. On Friday, June 3, 2022 at 1:45:39 PM UTC-4 Jason Hoppes wrote: > I would like to generate the following SQL using the ORM. I am testing for > no rows ret

[sqlalchemy] Get the row count from a query

2022-06-03 Thread Jason Hoppes
, Jason -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you

[sqlalchemy] Re: sqlalchemy.exc.UnboundExecutionError

2022-05-17 Thread Jason Hoppes
I found my error It was in the logic. Thank you for taking the time to read. - Jason On Tuesday, May 17, 2022 at 4:51:49 PM UTC-4 Jason Hoppes wrote: > I am getting an exception: > > sqlalchemy.exc.UnboundExecutionError: Could not locate a bind configured > on mapper mapped class

[sqlalchemy] sqlalchemy.exc.UnboundExecutionError

2022-05-17 Thread Jason Hoppes
urn id_ I tried adding: session = Session.configure(bind=self.engine) in the with block but it told me configure is not an attribute of session. Any help would be appreciated thank you. - Jason -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To

Re: [sqlalchemy] Session within a session

2022-04-29 Thread Jason Hoppes
Sorry I got diverted on another project. I will try this later and let you know. Thanks for your help. - Jason On Wednesday, April 20, 2022 at 8:45:39 PM UTC-4 Mike Bayer wrote: > you can work with multiple sessions and their objects simultaneously, with > the provision that you don

Re: [sqlalchemy] query many-many with asssociation table

2022-04-29 Thread Jason Hoppes
Thanks Simon this worked. - Jason On Wednesday, April 6, 2022 at 6:26:51 AM UTC-4 Simon King wrote: > I think it should work if you join to the *relationship* explicitly > > ie. > > session.query(User).join(User.user_groups).filter(...) > > Hope that helps, > > Simo

Re: [sqlalchemy] query many-many with asssociation table

2022-04-29 Thread Hoppes, Jason
> On Tue, Apr 5, 2022 at 9:48 PM Jason Hoppes < > jason.hop...@stormfish-sci.com> wrote: > >> I want to select all users in a particular group. I have a users table, >> user_groups table, and a users_group_users_asc table to associate the two. >> Note this is not a

[sqlalchemy] Session within a session

2022-04-20 Thread Jason Hoppes
an inner session. Thanks in advance for your help. - Jason -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full

[sqlalchemy] query many-many with asssociation table

2022-04-05 Thread Jason Hoppes
use the .select_from() method to establish an explicit left side, as well as providing an explicit ON clause if not present already to help resolve the ambiguity. Thank you in advance for your help. - Jason -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http

Example of inline autogenerated use?

2020-11-04 Thread Jason Pascucci
I couldn't lay my hands on an example of using MigrationContext(connect=) and running the results of produce_migrations(Base.metadata, mc). I got close, I think, evaling the results of render_python_code (which failed due to spaces, but I can wrap it into a def, I guess), but I think there's

[sqlalchemy] Re: Querying an Association Proxy using an enum column in the intermediate table

2019-04-22 Thread Jason Armstrong
Here is an update to the original that now works, implementing Mike's solution of a single table inheritance for the association object. Thank you again! from sqlalchemy import Column, ForeignKey, Enum, Text, Integer, create_engine from sqlalchemy.orm import relationship, backref,

Re: [sqlalchemy] Querying an Association Proxy using an enum column in the intermediate table

2019-04-22 Thread Jason Armstrong
ble in the enum, if that were a concern. Thanks for the tip. I thought I might be going about it the wrong way, and I'll have a go at implementing your suggestion. Regards, -- Jason Armstrong -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To p

[sqlalchemy] Querying an Association Proxy using an enum column in the intermediate table

2019-04-21 Thread Jason Armstrong
Hello everyone, I am modelling a relationship between two groups which is a many-to-many relationship, with an additional constraint. I have an Employer and a Worker class. Employers can have a relationship to a worker in a number of ways, which I'm representing by an enum: Contractor,

[sqlalchemy] Re: GlobalFilter recipe

2017-10-31 Thread Jason Gosnell
Minor correction to the above: I observed that in 1.0.0+, TemporalOption.*process_query_conditionally* is never called (hence the None/None for temporal_lower/temporal_upper in the resulting query). Jason On Tuesday, October 31, 2017 at 9:47:39 PM UTC-7, Jason Gosnell wrote: > > Hi

[sqlalchemy] GlobalFilter recipe

2017-10-31 Thread Jason Gosnell
ren == [c5] AssertionError I backtracked to sqlalchemy 0.9.10 to confirmed it works as advertised, and then rolled forward to 1.0.0 to confirmed it fails. I also observed that in 1.0.0+, TemporalOption.process_query is never called. Thanks, Jason -- SQLAlchemy - The Python SQL Toolkit

Re: [sqlalchemy] Re: Help with ORM join syntax

2017-04-03 Thread Jason T.
; query.join(bus1_alias, ). > > > > > > On 04/03/2017 04:53 PM, Jason T. wrote: > > Okay. I figured out how to use the ORM without joins, but I still can't > > figure out how to use the joins. :( > > > > bus1_alias = aliased(sam.Bus) &g

[sqlalchemy] Re: Help with ORM join syntax

2017-04-03 Thread Jason T.
(bus1_alias.number == bus1). \ filter(bus2_alias.number == bus2).first() On Monday, April 3, 2017 at 1:29:49 PM UTC-5, Jason T. wrote: > > All, > > I am able to join two tables and get the desired result with the below SQL > syntax; however, I am having trouble translating this SQL to the ORM

[sqlalchemy] Help with ORM join syntax

2017-04-03 Thread Jason T.
All, I am able to join two tables and get the desired result with the below SQL syntax; however, I am having trouble translating this SQL to the ORM join syntax. Any help will be appreciated. SELECT * FROM raw.branch as b JOIN raw.bus AS bus1 ON bus1.id = b.id_from_bus AND bus1.id_model

[sqlalchemy] Re: Default behavior for sqlalchemy_utils.UUIDType

2016-08-02 Thread Jason Libbey
format. At any rate, I've got it fixed now, thanks so much Mike! On Friday, July 29, 2016 at 6:45:01 PM UTC-7, Jason Libbey wrote: > > Hi, this is my first post, so if it does not adhere by your guidelines, > please let me know and I'll fix it ASAP. > > I'm using the sqlalchemy

[sqlalchemy] Default behavior for sqlalchemy_utils.UUIDType

2016-07-29 Thread Jason Libbey
Hi, this is my first post, so if it does not adhere by your guidelines, please let me know and I'll fix it ASAP. I'm using the sqlalchemy_utils.UUIDType as per backend-agnostic-guid-type . from

Re: [sqlalchemy] session flush inserts performing VERY slow for MS Sql Server

2016-03-07 Thread Jason Brownstein
bc:///?odbc_connect={}".format(quoted) > > ECHO = None # "debug" > > > class Customer(Base): > __tablename__ = "customer" > id = Column(Integer, primary_key=True) > name = Column(String(255)) > > def init_sqlalchemy(dbname='jason'):

Re: [sqlalchemy] running parallel migrations using sharded/partioned/spaced queries?

2015-10-14 Thread jason kirtland
If you can partition the rows numerically, this is trivially easily to implement using redis as the orchestrator. For example if you have integer PKs, you might have a loop like: offset = 0 while offset < tablesize: for row in query[offset:batchsize]: migrate(row)

Re: [sqlalchemy] Sending queue messages/emails after model commit

2014-09-22 Thread jason kirtland
Hi Alex, I have a similar use case, and fixed it by buffering the signals until the session transaction completes. On rollback, the buffered signals are discarded; on successful commit, the signals are truly emitted. Cheers, Jason On Mon, Sep 22, 2014 at 2:20 AM, Alex Michael alex

Re: [sqlalchemy] unit tests failing on 0.9.6

2014-07-09 Thread Jason Newton
it might be hitting? On 7/8/14, 5:56 PM, Jason Newton wrote: Any thoughts on why the unit testing is failing? platform linux2 -- Python 2.7.6 -- py-1.4.20 -- pytest-2.5.2 -- /usr/bin/python == 5776 passed, 688 skipped in 139.77

Re: [sqlalchemy] unit tests failing on 0.9.6

2014-07-09 Thread Jason Newton
problematic. issue appeared in 0.9.6, not 0.9.5 ? On 7/9/14, 3:01 AM, Jason Newton wrote: Yes, it seems to me like it gets to the end and then commits suicide just before returning, but I wasn't able to make heads or tails. Nothing fancy to running it - just unpack the pypi archive

[sqlalchemy] unit tests failing on 0.9.6

2014-07-08 Thread Jason Newton
= [self.loadTestsFromName(name, module) for name in names] File /usr/lib64/python2.7/unittest/loader.py, line 122, in loadTestsFromName (obj, test)) TypeError: calling function main at 0x2d3b500 returned 0, not a test -Jason -- You received this message because you are subscribed to the Google Groups

[sqlalchemy] postgresql large objects

2014-06-25 Thread Jason Newton
tables reference these large objects via oids, something like smart pointers in postgres. It'd be great to plug large objects into sqlalchemy properly - but can it be done? -Jason -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe

Re: [sqlalchemy] postgresql large objects

2014-06-25 Thread Jason Newton
when these types are in play it might be something that can occur at that level, PG's type API is obviously a lot more PG specific. -Jason -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails

Re: [sqlalchemy] postgresql large objects

2014-06-25 Thread Jason Newton
Just in case this wasn't apparent, you certainly *can* use psycopg2's bindings when you're in an otherwise SQLAlchemy app. Worst case you can retrieve a raw psycopg2 connection using connection.raw_connection and do whatever you need. If you truly have some use for LOBs, SQLAlchemy isn't

[sqlalchemy] Any progress on friend relationships, aka bi-directional self-referencing many-to-many

2014-05-29 Thread Jason Wirth
are from 2012. Has there been any development on these kinds of relationships or are Mike's answers still the best known solutions? Best, Jason -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails

Re: [sqlalchemy] matches_any: an extension to the Query object, and a HSTORE attribute access property

2014-01-07 Thread jason kirtland
On Tue, Jan 7, 2014 at 11:14 AM, Philip Scott safetyfirstp...@gmail.comwrote: Hi folks, SQLAlchemy is at the heart of what we do at work (UK based hedge fund); so first of all a big thank you; I am not quite sure where we'd be without you. We would like to give back to the community as much

Re: [sqlalchemy] testing for an association proxy (possible bug and patch included)

2013-08-23 Thread jason kirtland
On Fri, Aug 23, 2013 at 2:31 PM, Gombas, Gabor (IT) gabor.gom...@morganstanley.com wrote: On Fri, Aug 23, 2013 at 12:11:39PM -0700, Jonathan Vanasco wrote: i think a simple fix could be something like this ( line 240, sqlalchemy/ext/associationproxy.py ) if self.scalar: -

Re: [sqlalchemy] Cross-schema foreign keys reflection

2013-08-14 Thread Jason
. Thanks for pointing out that page. I also needed to add the schema to the foreign key declarations. eg Column(Integer, ForeignKey('otherschema.othertable.id')) instead of Column(Integer, ForeignKey('othertable.id')) -- Jason -- You received this message because you are subscribed to the Google

[sqlalchemy] Latest sphinx with autodoc may fail with SQLAlchemy models

2013-04-11 Thread Jason
that the RelationshipProperty can't handle having repr() being called on it. -- Jason -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com

[sqlalchemy] Re: Advice: Best practice for working with an existing database

2013-03-22 Thread Jason
this to be annoying (I would constantly forget how the table names compared to the class names). -- Jason -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy

[sqlalchemy] 0.8.0b Postgres Array Issue

2013-03-07 Thread Jason
-dimensional list for the discounts value instead of a list of namedtuples. The documentation doesn't mention this side-effect of the array improvements, is this a bug in 0.8.0b? Thanks, Jason -- You received this message because you are subscribed to the Google Groups sqlalchemy group

Re: [sqlalchemy] 0.8.0b Postgres Array Issue

2013-03-07 Thread Jason
it can be converted into a list. -- Jason -- You received this message because you are subscribed to the Google 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

Re: [sqlalchemy] Postgres custom composite types

2013-03-05 Thread Jason
On Tuesday, March 5, 2013 11:09:00 AM UTC-5, Michael Bayer wrote: On Mar 5, 2013, at 9:45 AM, Jason ja...@deadtreepages.com javascript: wrote: Hello, I'm looking or some direction on how to implement the SQL syntax when querying Postgres' composite types. In case you're

Re: [sqlalchemy] Postgres custom composite types

2013-03-05 Thread Jason
On Tuesday, March 5, 2013 2:52:59 PM UTC-5, Jason wrote: On Tuesday, March 5, 2013 11:09:00 AM UTC-5, Michael Bayer wrote: On Mar 5, 2013, at 9:45 AM, Jason ja...@deadtreepages.com wrote: Hello, I'm looking or some direction on how to implement the SQL syntax when querying

[sqlalchemy] Re: max() min() string lengths?

2013-01-04 Thread Jason
(func.max(func.length(Word.word)), func.min(func.length(Word.word))) -- Jason -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/eZI3kq2cjUMJ. To post

[sqlalchemy] flush overflow counter debug

2012-12-04 Thread Jason
a Pyramid application, so I am somewhat removed from the commit logic. Thanks, Jason -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/3fP5zscycEQJ. To post

Re: [sqlalchemy] flush overflow counter debug

2012-12-04 Thread Jason
Session.autoflush to false before the loop and then set it back to true afterwards it works. On Tuesday, December 4, 2012 3:16:24 PM UTC-5, Michael Bayer wrote: On Dec 4, 2012, at 3:04 PM, Jason wrote: After upgrading to SQLAlchemy 0.7.9 I know receive an error FlushError: Over 100 subsequent

Re: [sqlalchemy] flush overflow counter debug

2012-12-04 Thread Jason
Disregard that, I spoke too soon. There is something going on after it starts the commit process. On Tuesday, December 4, 2012 3:35:40 PM UTC-5, Jason wrote: Does this mean there is a limit to the number of queries I can run in a transaction? For example I am looping about 20 times

Re: [sqlalchemy] flush overflow counter debug

2012-12-04 Thread Jason
that line there is only a single flush at the commit time. It looks correct according to the examples I have seen, but if you know why it keeps setting them as dirty please let me know. On Tuesday, December 4, 2012 3:16:24 PM UTC-5, Michael Bayer wrote: On Dec 4, 2012, at 3:04 PM, Jason

Re: [sqlalchemy] flush overflow counter debug

2012-12-04 Thread Jason
On Tuesday, December 4, 2012 4:15:03 PM UTC-5, Jason wrote: Ok I figured out the cause, but not the solution. I am using a mutable type for hstore columns. I have a UserDefinedType for Hstore that just passes everything through to psycopg2's hstore type: class HStore(UserDefinedType

[sqlalchemy] determine if relationship is a backref

2012-08-15 Thread Jason
on the current table or not. So for Department.employees it would be False because the relationship was defined as a backref from another table. Is there a method/technique to accomplish this? Thanks, Jason -- You received this message because you are subscribed to the Google Groups

Re: [sqlalchemy] determine if relationship is a backref

2012-08-15 Thread Jason
= True Thanks for the help, Jason -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/5GZlYjt8TQQJ. To post to this group, send email to sqlalchemy

[sqlalchemy] How do I do this SQL query in SQLAlchemy?

2012-07-02 Thread Jason Phillips
I have a MySQL database with the following structure and was hoping someone could help me convert the SQL query below to SQLAlchemy. *Database structure:* *bottom:* id name middle_id *middle:* id name top_id *top:* id name *Here are my

[sqlalchemy] Arrays with altered elements

2011-08-04 Thread Jason
the func.dmetaphone call within the array. Is there a way to force it to do that? Thanks, Jason -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/Rv742SjyArEJ

Re: [sqlalchemy] Arrays with altered elements

2011-08-04 Thread Jason
I suppose then the simplest solution is to make a function in the database that will execute a function on each element of an array and use: .having(func.array_agg(metaphones.columns.mphone).op('@')(func.metaphone_array(terms))) This seems to work fine. Thanks, Jason -- You received

[sqlalchemy] Re: Full-fledged objects as mapped attributes?

2011-07-01 Thread Jason Denning
in conjunction with a TypeDecorator, so that the data is coerced both at the database level, as well as at the attribute setter level - this is athttp://www.sqlalchemy.org/trac/wiki/UsageRecipes/ValidateAllOccurrenc On Jun 29, 2011, at 9:40 PM, Jason Denning wrote: Hi All, I am

[sqlalchemy] Full-fledged objects as mapped attributes?

2011-06-29 Thread Jason Denning
attempting this type of thing, or am I totally crazy? Thanks, Jason -- 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 sqlalchemy+unsubscr

Re: [sqlalchemy] execute at beginning of every session

2011-02-16 Thread Jason McKellar
On Wed, Feb 16, 2011 at 11:51 AM, Michael Bayer mike...@zzzcomputing.comwrote: On Feb 16, 2011, at 10:22 AM, Landreville wrote: Is there a way to run a command at the beginning of every session, before anything else is run? SessionExtension has an after_begin() hook for this purpose.

Re: [sqlalchemy] association_proxy as property?

2010-11-16 Thread jason kirtland
On Tue, Nov 16, 2010 at 9:05 AM, A.M. age...@themactionfaction.com wrote: On Nov 16, 2010, at 11:43 AM, Michael Bayer wrote: On Nov 16, 2010, at 11:14 AM, A.M. wrote: To generate json from our SQLAlchemy model objects, we are using iterate_properties to determine how to dictify the object.

Re: [sqlalchemy] Inheriting custom collection to create another custom collection. Issues with the appenders/parents

2010-11-13 Thread jason kirtland
with that dict that's declared to be emulating a set. Cheers, Jason I thought... ok, ok... let's just explicitly add the 'appender' to the ContainerOfB class...  The only thing I need to do is calling the appender of the super class, anyway... no biggie and so I did: def ContainerOfB(ContainerOfA

[sqlalchemy] Re: Is there a way to globally set DateTime string formatting?

2010-09-27 Thread Jason Baker
On Sep 24, 7:09 pm, Michael Bayer mike...@zzzcomputing.com wrote: If you have a stringified date format that you'd like to pass to SQL statements as values, such that the string is parsed into a datetime then passed to the DBAPI, just use TypeDecorator around

[sqlalchemy] Re: Why isn't this Json column type working?

2010-09-19 Thread Jason Baker
On Sep 18, 9:08 pm, Michael Bayer mike...@zzzcomputing.com wrote:  You might after that also throw a pdb into the process_bind_param() method and ensure that its being called Sorry, I should have been more clear about this. If I add a print statement in process_bind_param it doesn't get

[sqlalchemy] Why isn't this Json column type working?

2010-09-18 Thread Jason Baker
')) data = Column(Json) export_date = Column(BigInteger) last_change = relationship('Change') I get the following error when I try to run it (with some sensitive data left out): Traceback (most recent call last): File /Users/jason/.envs/main/bin/epfimport, line 8, in module

[sqlalchemy] Slides from the Advanced SQLAlchemy Customization tutorial at EuroPython

2010-07-19 Thread jason kirtland
, Jason -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http

Re: [sqlalchemy] Re: blocking on Base.metadata.drop_all() in test

2010-07-08 Thread jason kirtland
Your scoped session still has an active connection, which is blocking the drop. Call session.remove() before the drop, or configure the session with expires_on_commit=False to not issue SELECTs to fetch object state after the final commit(). On Thu, Jul 8, 2010 at 9:27 AM, zende

[sqlalchemy] Re: Help with optimizing

2010-06-02 Thread Jason Baker
On May 30, 8:39 pm, Michael Bayer mike...@zzzcomputing.com wrote: OK well by re018792aea57 I've bumped the callcounts down a *little*, reducing compiler overhead within the flush().     Perhaps it will be a bigger difference for your app which seems to be heavy on flush() calls. As it turns

Re: [sqlalchemy] Help with optimizing

2010-05-28 Thread Jason Baker
the usage of a session-spanning compilation cache. That would be a *huge* help. Would this involve a custom Query subclass? -- Jason Baker Developer ZeOmega 3010 Gaylord Parkway, Suite 210 Frisco, TX 75034 O: 214-618-9880 ext 8024 jba...@zeomega.com www.ZeOmega.com Proven. Progressive. Partner

Re: [sqlalchemy] Sql alchemy-Oracle Error

2010-05-05 Thread Jason Baker
On Wed, May 5, 2010 at 7:42 AM, dhanil anupurath dhanilanupur...@gmail.comwrote: Hi I am using sqlalchemy in my TurboGears application. some of my classes has columns with Pickletype dataType. these get converted to BLOB dataType in the database. I was using mySql till recently and

Re: [sqlalchemy] session lifecycle and wsgi

2010-04-28 Thread jason kirtland
On Wed, Apr 28, 2010 at 7:52 AM, Chris Withers ch...@simplistix.co.uk wrote: Diana Clarke wrote: Finally, we're using pylons and are removing the contextual session in the finally clause of the base controller's __call__ method. class BaseController(WSGIController):    def __call__(self,

Re: [sqlalchemy] session lifecycle and wsgi

2010-04-28 Thread jason kirtland
On Wed, Apr 28, 2010 at 8:55 AM, Chris Withers ch...@simplistix.co.uk wrote: jason kirtland wrote: On Wed, Apr 28, 2010 at 7:52 AM, Chris Withers ch...@simplistix.co.uk wrote: Diana Clarke wrote: Finally, we're using pylons and are removing the contextual session in the finally clause

Re: [sqlalchemy] Mapping dictionaries with string keys and record values

2010-04-26 Thread jason kirtland
it wasn't that way already, and I'd want to hear from Jason Kirtland, its author, on if we are missing something or otherwise whats up.   I have a vague notion that there was a reason for this, or maybe not. It's not something that can be easily solved in the general case with the current API

[sqlalchemy] Mapper table properties

2010-04-23 Thread Jason Baker
Given an entity class (or entity instance), I'd like to get the table that is mapped to it. If I get the mapper using object_mapper/class_mapper, then I get a mapper with the following properties defined (among others): local_table, mapped_table, and tables. Can someone help me understand what

Re: [sqlalchemy] Can I log queries from where they're created?

2010-04-06 Thread Jason Baker
not thinking of? -- Jason Baker Developer ZeOmega 3010 Gaylord Parkway, Suite 210 Frisco, TX 75034 O: 214-618-9880 ext 8024 jba...@zeomega.com www.ZeOmega.com Proven. Progressive. Partner. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post

[sqlalchemy] envbuilder setup for sqlalchemy

2010-04-06 Thread Jason Baker
Hello, Just in case anyone can use this, I've created a sample envbuilder file that will create a virtualenv with sqlalchemy installed from hg. The file is here: http://github.com/jasonbaker/envbuilder/blob/master/examples/sqlalchemy/.env To use it: 1. Install the development version of

[sqlalchemy] Can I log queries from where they're created?

2010-04-05 Thread Jason Baker
Here's what I'd like to do. Suppose I have some class Foo in some_module.py: class Foo(Entity): def all_foos(self): return self.session.query(Foo).all() ...sqlalchemy by default will log this to sqlalchemy.engine. However, this makes it a bit difficult to narrow down

Re: [sqlalchemy] error handling for sessionmaker function

2010-01-11 Thread jason kirtland
On Mon, Jan 11, 2010 at 4:07 PM, Manlio Perillo manlio.peri...@gmail.com wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi. I'm updating some of my code to SQLALchemy 0.6, and I have noted a problem with the sessionmaker function. The problem is a compatibility one: old versions use

[sqlalchemy] Re: Modify the start number of a sequence after it's been created

2009-12-16 Thread Jason R. Coombs
Here's what I do. First, I get the sequence f rom the table's columns seq = table.c.id.default # or if you have a mapper-class # seq = MyClass.id_property.property.columns[0].default Then, I execute that sequence to advance the sequence until it's the value needed. engine.execute(seq) The

[sqlalchemy] KeyError in getting session_identity_map[identitykey]

2009-12-11 Thread Jason
be removing the key? Any help would be greatly appreciated. Jason -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr

[sqlalchemy] Re: KeyError in getting session_identity_map[identitykey]

2009-12-11 Thread Jason
/thread? On Dec 11, 11:34 am, Michael Bayer mike...@zzzcomputing.com wrote: Jason wrote: I'm seeing a keyerror in mapper.py where it does: instance = session_identity_map[identitykey] The strange this is, I see the code doing a check to make sure identitykey is in the session_identity_map

[sqlalchemy] Re: MySQL has gone away (again)

2009-06-08 Thread jason kirtland
, with a simple pool event listener you can ensure the liveliness of connections before the pool hands them out for use. Usage example is attached. Cheers, Jason class LookLively(object): Ensures that MySQL connections checked out of the pool are alive. def checkout(self, dbapi_con

[sqlalchemy] Re: moving an object

2009-04-05 Thread jason kirtland
jean-philippe dutreve wrote: Hi all, I wonder if SA can handle this use case: An Account can contain Entries ordered by 'position' attribute. mapper(Account, table_accounts, properties = dict( entries = relation(Entry, lazy=True, collection_class=ordering_list ('position'),

[sqlalchemy] Re: Suggestions on using a dialect outside of the Alchemy installation tree

2009-03-10 Thread jason kirtland
It'd look like this: http://code.google.com/p/ibm-db/source/browse/trunk/IBM_DB/ibm_db_sa/setup.py Your dialect will be available to SA after you 'python setup.py install' or 'python setup.py develop' in your -ase distribution. phrrn...@googlemail.com wrote: Thanks Mike. This sounds great

[sqlalchemy] Re: Problems/Bug in ordering_list (UNIQUE KEY violation)

2009-02-26 Thread jason kirtland
? When I delete on entry with: del short_trip.trip_stops[1] and then flush() and commit(). The ordering_list has to do some work in the corresponding database table. im not sure, perhaps Jason can chime in on this For this constraint configuration you might try making the DB constraint

[sqlalchemy] Re: how to handle Date values of the form YYYY-MM-00

2009-02-01 Thread jason kirtland
rdmur...@bitdance.com wrote: I have an existing MySQL database (that I do not control) with schema fields defined using the 'Date' type. The values that occur in these fields often have a 'day' of '00', and sometimes a month of '00', and sometimes the field's value is -00-00. The zeros

[sqlalchemy] Re: how to handle Date values of the form YYYY-MM-00

2009-02-01 Thread jason kirtland
rdmur...@bitdance.com wrote: Quoth jason kirtland j...@discorporate.us: rdmur...@bitdance.com wrote: I have an existing MySQL database (that I do not control) with schema fields defined using the 'Date' type. The values that occur in these fields often have a 'day' of '00', and sometimes

[sqlalchemy] Re: find only loaded objects in relation collections

2009-01-30 Thread jason kirtland
GHZ wrote: Hi, I have a Subscriber and an Address table. Subscriber can have many Addresses mapper(Subscriber, subscriber_table, properties={ 'addresses' : relation(Address, collection_class=Addresses, backref='customer')}) From the a Subscriber object, I want to inspect all

[sqlalchemy] Re: INSERT ... ON DUPLICATE KEY UPDATE

2009-01-23 Thread jason kirtland
camlost wrote: Thank you for the reply. However, this solution (though I'm ready to use it) would create a lot of SQL queries comparing it with simple INSERT ... ON DUPLICATE KEY UPDATE. On the other hand, I admit the INSERT ... IN DUPLICATE KEY UPDATE might not be available in other DBs.

[sqlalchemy] Re: passing tuple argument into sqlalchemy.sql.text string

2009-01-21 Thread jason kirtland
Faheem Mitha wrote: On Wed, 21 Jan 2009 08:26:13 -0800, jason kirtland j...@discorporate.us wrote: Faheem Mitha wrote: Hi, I've got a query as follows: from sqlalchemy.sql import text gq = text( SELECT decode_genotype(cell.snpval_id, snp.allelea_id, snp.alleleb_id) FROM cell JOIN

[sqlalchemy] Re: default=0.0 on Float Column produces `col` float default NULL

2008-11-10 Thread jason kirtland
Simon wrote: Hi all, I'm using SA 0.5.0rc3 and MySQL 5.0.51a on Mac OS X 10.4.11. I have a table with a float column and would like to have a default value of 0: Column('col', Float(), default=0.0) However, executing metadata.create_all(engine) yields CREATE TABLE `Table` ( ...

[sqlalchemy] Re: default=0.0 on Float Column produces `col` float default NULL

2008-11-10 Thread jason kirtland
With 0.4 it's a positional argument to Column: Column('col', Float(), PassiveDefault('0.0')) Simon wrote: Thanks Jason! Is there any way of doing this in SA 0.4 as well? On 10 Nov., 16:42, jason kirtland [EMAIL PROTECTED] wrote: Simon wrote: Hi all, I'm using SA 0.5.0rc3 and MySQL

[sqlalchemy] Re: foreign key problem when using reflection and schemas

2008-10-27 Thread jason kirtland
That should be working now in r5203. The reflection code was missing an edge case where an explicit schema= is the same as the connection's schema. Switching those to schema=None should work as intended if you need a workaround on a released version. Cheers, Jason Martijn Faassen wrote

[sqlalchemy] Re: in_( bindparam(list) ) ?

2008-10-13 Thread jason kirtland
Michael Bayer wrote: On Oct 13, 2008, at 10:58 AM, [EMAIL PROTECTED] wrote: On Monday 13 October 2008 17:21:31 Michael Bayer wrote: On Oct 13, 2008, at 6:41 AM, [EMAIL PROTECTED] wrote: why i cannot give in_() a bindparam? q.filter( x.in_( somelistorset )) works q.filter( x.in_(

[sqlalchemy] Re: Aw: [sqlalchemy] Re: 0.4: can not append objects to instrumentedlists

2008-10-13 Thread jason kirtland
[EMAIL PROTECTED] wrote: I spent some time to migrate to sqlalchemy 0.4 and it's to late to go back to 0.3. What can I do to add objects to properties (InstumentedLists) in sqlalchemy 0.4 (with different mappers)? I suspect that case will work if you add the user to the session under the

[sqlalchemy] Re: reflection unavailable for mysql temporary tables?

2008-10-13 Thread jason kirtland
Andy Davidoff wrote: On Oct 11, 1:29 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Oct 11, 2008, at 12:49 PM, AndyDavidoffwrote: This fixes the first part of this problem, but unfortunately the `show create table` is performed in the connection, not the session in which the temporary table

[sqlalchemy] Re: SA 0.5 rc1 - Mysql Unicode(1) decode error

2008-10-10 Thread jason kirtland
Martijn Moeling wrote: Hi I needed a Unicode(1) Column in one of my tables. It was translated into a char(1) column in MySQL. When querying the table, I get a: AttributeError: 'Set' object has no attribute 'decode' Which disappears if I make the column a

[sqlalchemy] Re: OrderingList and list.sort()

2008-10-10 Thread jason kirtland
Adam Dziendziel wrote: Hi, It seems that sorting of ordering list doesn't work. Attribute object.items is an OrderingList: object.items.sort(cmp=my_cmp) The list is sorted, but the ordering column is not updated. I need to call explicitly: object.items._reorder() Maybe override

[sqlalchemy] Re: mysql utf8 encoding problem

2008-10-09 Thread jason kirtland
Michael Bayer wrote: On Oct 8, 2008, at 8:54 PM, jason kirtland wrote: Most likely you just need to configure the db-api's client encoding by adding ?charset=utf8 onto your connection URL. Enough folks have hit this recently that I'm (again) considering passing through the engine

[sqlalchemy] Re: mysql utf8 encoding problem

2008-10-09 Thread jason kirtland
Michael Bayer wrote: On Oct 9, 2008, at 3:39 AM, jason kirtland wrote: i don't know about your env, but the unit tests under mysql use testing.engines.utf8_engine to configure a connection that can send unicode across the wire without encoding failures. I can run python test/sql

[sqlalchemy] Re: mysql utf8 encoding problem

2008-10-08 Thread jason kirtland
joelanman wrote: Hi, Firstly - I'm hugely impressed with SQLAlchemy - it's really helped me a lot with my new project. I'm having problems storing international characters in mysql using SQLAlchemy. For example: école—school looks like this in mysql: école—school I'm

[sqlalchemy] Re: adding children to ORM object using property causes problems, maybe a bug?

2008-10-02 Thread jason kirtland
Randy Syring wrote: After some work with Gedd on #sqlalchemy, it seems that adding children to a parent object using a custom property() doesn't work as we expected it would. A test case is here: http://paste.pocoo.org/show/86848/ The error is triggered by line #53. Are we doing

[sqlalchemy] Re: reflection unavailable for mysql temporary tables?

2008-09-27 Thread jason kirtland
Andy Davidoff wrote: Reflection of temporary tables under MySQL works around revision 4000 and probably as recently as May but doesn't seem to work under revision 5000 or later; I get a NoSuchTableError. Is this change intentional? If the only change I make to my code is to create and

[sqlalchemy] Re: Unicode Results from SQL functions

2008-09-25 Thread jason kirtland
Shawn Church wrote: On Wed, Sep 24, 2008 at 10:45 PM, jason kirtland [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Adding ?charset=utf8use_unicode=1 to your MySQL connection URL is a much easier way to get Unicode back from all DB access. Ok, that works. I thought

[sqlalchemy] Re: Fwd: Support for ordered lists of child items

2008-09-24 Thread jason kirtland
Emmett Lazich wrote: Thank you Jason. orderinglist looks like what I am after! Is your orderinglist plugin fully functional in 0.4.7p1? Yep. Before I attempt it, pls advise if there any technical reason preventing the integration of orderinglist into the basic_tree.py (adjacency list

[sqlalchemy] Re: Unicode Results from SQL functions

2008-09-24 Thread jason kirtland
Shawn Church wrote: On Wed, Sep 24, 2008 at 7:37 PM, Michael Bayer [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: we can of course add more functions to the list of known functions such as ifnull() (it would be best if ifnull() is a SQL standard function, I'm not sure

  1   2   3   >