Re: [sqlalchemy] MX Linux Python3 sqlalchemy hangs on ROLLBACK

2021-05-12 Thread Rob Marshall
Hi Mike, I'll see if I can separate the specific DataFrame that was causing the problem. Thanks, Rob On Tuesday, May 11, 2021 at 7:42:28 PM UTC-4 Mike Bayer wrote: > this does mean there's a bug in the mariadb driver, if you can provide a > reproducing test case > > > On Tu

Re: [sqlalchemy] MX Linux Python3 sqlalchemy hangs on ROLLBACK

2021-05-11 Thread Rob Marshall
Hi Mike, Apparently it was the driver. I changed the create_engine to: engine = create_engine('mysql://user:password@127.0.0.1/options') And that appears to handle that particular insert without issue. Thank-you, Rob On Tuesday, May 11, 2021 at 10:41:13 AM UTC-4 Mike Bayer wrote: >

[sqlalchemy] MX Linux Python3 sqlalchemy hangs on ROLLBACK

2021-05-11 Thread Rob Marshall
= create_engine('mariadb+mariadbconnector://user:password@127.0.0.1/options') The original data collected is returned as a Python dictionary, and I convert each of the rows of calls/puts by expiration date to a Pandas data frame and use to_sql() to update the database. Thank-you, Rob

[sqlalchemy] How to refer to columns whose names begin with a number when autoloading?

2021-04-11 Thread Rob Rosenfeld
to access a property named "1st_period" yields a SyntaxError Thanks, Rob SELECT TOP 10 [1st_period] FROM Students; class Student(Model): __table__ = Table("Students", metadata, autoload=True, autoload_with=engine) @property def first_period(self): return self.1st_period --

Re: [sqlalchemy] Many-to-many using custom join columns and autoloaded tables

2020-07-22 Thread Rob Rosenfeld
).join(Student.details) > > the different ways to join are laid out at > > > https://docs.sqlalchemy.org/en/13/orm/query.html?highlight=query%20join#sqlalchemy.orm.query.Query.join > > > > On Tue, Jul 21, 2020, at 9:40 PM, Rob Rosenfeld wrote: > > > Hi All, > >

[sqlalchemy] Many-to-many using custom join columns and autoloaded tables

2020-07-21 Thread Rob Rosenfeld
are autoloaded from the database schema. I've been doing fine until I hit this association object pattern. Can you please offer any advice? Thanks, Rob In the end my goal is to execute the following and have it issue a single statement to the database. results = Class.query.join(Enrollment

[sqlalchemy] alembic (1.4.2) revision --autogenerate hang

2020-06-18 Thread Rob Schottland
I'm trying to do "alembic revision --autogenerate" I get the usual warnings (that I've gotten in previous successful runs) Here's the console output alembic$ alembic revision --autogenerate INFO [alembic.runtime.migration] Context impl PostgresqlImpl. INFO [alembic.runtime.migration] Will

Re: [sqlalchemy] Retaining plain old python instance member values betwen Flask-SQLAlchemy requests.

2020-02-22 Thread Rob Rosenfeld
.__data_cache.get(self.id) if data is None: User.__data_cache[self.id] = 0 User.__data_cache[self.id] += 1 Rob On Wednesday, February 12, 2020 at 9:43:37 PM UTC-6, Rob Rosenfeld wrote: > > Thanks for the thoughts. I'm going to digest, read docs, and experiment. > > > On We

Re: [sqlalchemy] Retaining plain old python instance member values betwen Flask-SQLAlchemy requests.

2020-02-12 Thread Rob Rosenfeld
Thanks for the thoughts. I'm going to digest, read docs, and experiment. On Wed, Feb 12, 2020 at 8:52 AM Mike Bayer wrote: > > > On Tue, Feb 11, 2020, at 11:41 PM, Rob Rosenfeld wrote: > > Hi All, > > I am using Flask-SQLAlchemy on a legacy database. My SQLA classes

[sqlalchemy] Retaining plain old python instance member values betwen Flask-SQLAlchemy requests.

2020-02-11 Thread Rob Rosenfeld
plain old python. Thanks for the help, Rob from flask import Flask from flask_sqlalchemy import SQLAlchemy from sqlalchemy import MetaData from sqlalchemy import orm app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = connection_string db = SQLAlchemy(app) class Owne

Re: [sqlalchemy] Filtering declarative by concatenated columns against Mircosoft SQL Server

2016-08-15 Thread rob
Server]Statement(s) could not be prepared. (8180) > > (SQLExecDirectW)')[SQL:'SELECT Person_1.[LastName] AS > > [dbo_Person_LastName], Person_1.[FirstName] AS > > [dbo_Person_FirstName]\nFROM dbo.Person AS Person_1 \nWHERE > > concat(Person_1.[FirstName], ?, Person_1.

[sqlalchemy] Filtering declarative by concatenated columns against Mircosoft SQL Server

2016-08-14 Thread rob
.[FirstName], ?, Person_1.[LastName]) LIKE ?'] [parameters: (' ', 'ob Smi')] I don't see any mention in the documentation of how to indicate the SQL Server version that queries should be compiled for. Any suggestions? Thanks, Rob -- You received this message because you are subscribed

[sqlalchemy] relationship joined to max() on a foreign table - help needed

2016-04-26 Thread Rob Fowler
Can anyone help me with this interesting (to me) relationship definition in sqla. I have some already defined data, not by me, that has, for each user, a foreign table of contact numbers, where the highest contact number is the one to use. For example, users: Harry, 1081, and Bob 1082

[sqlalchemy] Re: Temporarily drop and re-create constraint

2015-10-31 Thread rob
and add back later. > > My goal is to not need to re-code the details of the foreign key at the > time I need to reapply it to the table. > > > Thanks much, > Rob > I've been working on this some more and have figured out something that works. I'm guessing it could be genera

[sqlalchemy] Temporarily drop and re-create constraint

2015-10-30 Thread rob
` and grabbing the data, I can directly grab the ForeignKey object of interest to delete from the table and add back later. My goal is to not need to re-code the details of the foreign key at the time I need to reapply it to the table. Thanks much, Rob -- You received this message because you

Re: [sqlalchemy] Referring to __tablename__ as defined by a mixin's delarative_attr

2015-08-31 Thread rob
ef / back_populates aren't one of them because > these have to do with the class mapping, rather than tables/columns which > is why the deferred approach is provided. > > You can make your own function that generates that @declared_attr in one > step to save on verbosity. > &g

[sqlalchemy] Referring to __tablename__ as defined by a mixin's delarative_attr

2015-08-30 Thread rob
the wrong value. Can you help me fix this? Thanks, Rob -- 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

Re: [sqlalchemy] Column vs Table constraints for Column(unique=True) in Postgres

2015-05-29 Thread rob
Thank Lucas. I've tried that as well. In all cases, SQLAlchemy always emits a table constraint. i.e., an additional CONSTRAINT clause in the CREATE TABLE command. Maybe I've poorly phrased my question and SQLAlchemy always emits table constraints? Here's an updated example. In all three

Re: [sqlalchemy] Column vs Table constraints for Column(unique=True) in Postgres

2015-05-29 Thread rob
Thanks. Makes sense. On Friday, May 29, 2015 at 10:12:07 AM UTC-5, Michael Bayer wrote: On 5/29/15 2:12 AM, r...@rosenfeld.to javascript: wrote: Thank Lucas. I've tried that as well. In all cases, SQLAlchemy always emits a table constraint. i.e., an additional CONSTRAINT clause

Re: [sqlalchemy] Column vs Table constraints for Column(unique=True) in Postgres

2015-05-17 Thread rob
Sorry it took my a while to test this, but I didn't see any difference in the SQL emitted. What did I miss? from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column from sqlalchemy import Integer from sqlalchemy import UniqueConstraint from sqlalchemy import

[sqlalchemy] Column vs Table constraints for Column(unique=True) in Postgres

2015-05-03 Thread rob
Is there a way to control whether DDL emitted by SQLAlchemy uses a column and/or table constraint for uniqueness? It seems the following class Part(Base): __tablename__ = 'part' third_party_id = Column(Integer, nullable=True, default=None, unique= True) emits a table constraint CREATE

Re: [sqlalchemy] How to output SQLAlchemy logger only to a file?

2015-03-19 Thread rob
-sqlalchemy-logger-only-to-a-file Thanks in advance, Rob -- 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+...@googlegroups.com

[sqlalchemy] How to output SQLAlchemy logger only to a file?

2015-03-19 Thread rob
=True) engine.connect() Cross posted from http://stackoverflow.com/questions/29114627/how-to-output-sqlalchemy-logger-only-to-a-file Thanks in advance, Rob -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop

Re: [sqlalchemy] dogpile cache async_creation_runner question (actually with sqlalchemy but the example has the sqla factored out)

2015-01-04 Thread Rob Fowler
Thanks for the reply Mike. The explanation is somewhat as expected. Based on this, to keep things simple and being bone lazy, I switched the the 'redis' backend, whose locking is outside of the process and works 100% with multiple threads out of the box. -- You received this message because

[sqlalchemy] dogpile cache async_creation_runner question (actually with sqlalchemy but the example has the sqla factored out)

2015-01-03 Thread Rob Fowler
system level mutex but I assumed that was the purpose of the underlying dogpile locking) This is the gist with my code: https://gist.github.com/mianos/72ba45aed2824875c1a6 Pretty much copied from the example. Thanks in advance. - Rob -- You received this message because you are subscribed

[sqlalchemy] How can I set table constraints with DeferredReflection?

2014-04-02 Thread Rob Crowell
I'm using the ORM and one of my tables does not have a primary key defined. I am also using DeferredReflection, and I can't seem to figure out how to defer the PrimaryKeyConstraint until Base.prepare() runs. Any pointers? Base = declarative_base(cls=DeferredReflection) class

Re: [sqlalchemy] Trouble filtering binary columns with tuple_ and an in_ clause against Postgres

2014-02-28 Thread Rob Crowell
and 0.9. On Feb 27, 2014, at 7:29 PM, Michael Bayer mik...@zzzcomputing.comjavascript: wrote: On Feb 27, 2014, at 4:38 PM, Rob Crowell rob.c...@moat.com javascript: wrote: # in_ clause with 1 STRING, 1 BINARY filter_cols = tuple_(HashTest.hash_val, HashTest.hash_type

[sqlalchemy] Trouble filtering binary columns with tuple_ and an in_ clause against Postgres

2014-02-27 Thread Rob Crowell
When I pass binary data to a multi-column in_ clause, I seem to be geting inconsistent results and I need some help! I did some testing with MySQL, Postgres, and Vertica (connecting via https://pypi.python.org/pypi/vertica-sqlalchemy/0.1). It appears MySQL works correctly but both Postgres

[sqlalchemy] Help with DeferredReflection and setting up an engine at runtime?

2014-02-17 Thread Rob Crowell
I am having a bit of trouble getting DeferredReflection working the way I want; not sure if I am overlooking something obvious or if I just don't really understand how it's supposed to work. I'm trying to define my models before creating my engine (this does not work): Base =

Re: [sqlalchemy] Help with DeferredReflection and setting up an engine at runtime?

2014-02-17 Thread Rob Crowell
Interesting, thanks Michael. I didn't realize autoload was implied when using DeferredReflection but that makes sense. Thanks! On Monday, February 17, 2014 7:17:34 PM UTC-5, Michael Bayer wrote: On Feb 17, 2014, at 6:23 PM, Rob Crowell robcc...@gmail.com javascript: wrote: I am having

[sqlalchemy] aliasing a CTE expression

2013-07-15 Thread Rob
to the select clause, or in a `from_obj` within the clause, simply blows the `with` statement off the top of the select. (if that makes any sense) Is there any way to accomplish this? Many thanks, Rob -- You received this message because you are subscribed to the Google Groups sqlalchemy group

[sqlalchemy] Re: aliasing a CTE expression

2013-07-15 Thread Rob
Thank you *so* much... And apologies for not having included the object set up ... I thought it'd obscure more than it showed... But for the record, the `generate_series` and `row_number() over()` are spot on :D On Monday, 15 July 2013 18:58:00 UTC+1, Rob wrote: (using sqlalchemy

[sqlalchemy] Including counts in query results

2013-06-03 Thread Rob Green
(User.id, meetingRoomCount, bathroomCount).first() But this returns the total number of meeting rooms and bathrooms in the database, not the ones that are specific to that user. I feel like I'm missing something simple here, anyone have any ideas? -Rob -- You received this message because you

Re: [sqlalchemy] Getting the entity name, ideally the ORM class in the shard selector?

2013-04-23 Thread Rob Fowler
So anyone else who asks this knows, the following works: A query with just a column: qq = session.query(Configuration.name) Normally I would loop, but in this case, taking just the first column: yy = qq.column_descriptions[0]['expr'] yy.expression.table.name gives: ''configurations”

Re: [sqlalchemy] Getting the entity name, ideally the ORM class in the shard selector?

2013-04-22 Thread Rob Fowler
If the query does not have a table in it we don't get the tables. For example, the following simple query gets a list of connection_strings column from the Connection table: aa = session.query(Connection.connection_string) aa.column_descriptions [{'aliased': False, 'expr':

[sqlalchemy] Getting the entity name, ideally the ORM class in the shard selector?

2013-04-21 Thread Rob Fowler
We are using the sharding module included in our application. Currently we are selecting shards based on field. This works really well, as the field that gets hashed to select the shard needs to be migrated to the other tables that exist only in that shard. Now we would like to have

Re: [sqlalchemy] Better approach to filtering a relationship collection than using contains_eager()?

2013-02-27 Thread Rob Crowell
or contains_eager or any of that yet. On Feb 27, 2013, at 2:07 AM, Rob Crowell robcc...@gmail.com javascript: wrote: Example code: https://gist.github.com/rcrowell/5045832 I have Person and Town tables, which are joined in a many-to-many fashion through a VisitedDestinations table. I

Re: [sqlalchemy] Better approach to filtering a relationship collection than using contains_eager()?

2013-02-27 Thread Rob Crowell
, VisitedDestinations.town).\ options(contains_eager(Person.visited_destinations, VisitedDestinations.town)).\ filter(Town.name.in_(['Atlanta', 'Memphis'])) On Feb 27, 2013, at 1:48 PM, Rob Crowell rob.c...@moat.com javascript: wrote: Sure! Here's the query I am attempting to replicate: SELECT

Re: [sqlalchemy] Better approach to filtering a relationship collection than using contains_eager()?

2013-02-27 Thread Rob Crowell
, at 2:40 PM, Rob Crowell rob.c...@moat.com javascript: wrote: Ah okay, so you do recommend the contains_eager approach. I guess this is exactly the use-case it is designed for? I always get a little scared when I try using advanced features of SQLAlchemy :) One last question. The query here

[sqlalchemy] Difference between ZopeTransactionExtension(keep_session=True) and sessionmaker(expire_on_commit=False)?

2013-02-19 Thread rob . crowell
I'm building a pyramid application using pyramid_tm and ZopeTransactionExtension. We've written a little subscriber on NewResponse that writes out some values to a log file about the current user (request.user.id) after each request. For anybody that knows pyramid pretty well, we set the

Re: [sqlalchemy] Complicated filter clause causes recursion depth exceeded exception

2013-01-22 Thread rob . crowell
Thanks Michael, Writing a big list of conditions and combining them with and_(*conditions) worked well. I was indeed querying like this before: for condition in conditions: q = q.filter(condition) print q On Friday, January 18, 2013 6:00:04 PM UTC-5, Michael Bayer wrote: On Jan 18,

[sqlalchemy] Complicated filter clause causes recursion depth exceeded exception

2013-01-18 Thread rob . crowell
I haven't boiled this down to a short test case yet, but when my WHERE clause gets especially long I start getting the recursion depth exceeded exception. Is this a well-known limitation of sqlalchemy? We're running this query in production currently without SQLAlchemy, and it performs fine,

[sqlalchemy] Re: Is it possible to define multiple model objects that refer to the same table?

2012-11-21 Thread Rob Crowell
...@zzzcomputing.com wrote: On Nov 16, 2012, at 2:59 PM, Rob Crowell wrote: Thanks for the help so far Michael!  I can explain a little more about what I'm trying to do (I'm using a fictional application here but I think it pretty accurately translates into my actual application). BACKGROUND

[sqlalchemy] Re: Is it possible to define multiple model objects that refer to the same table?

2012-11-16 Thread Rob Crowell
On Nov 15, 10:48 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Nov 15, 2012, at 7:33 PM, Rob Crowell wrote: Sorry, that got cut off at the end. class IssueTag(Base):     __tablename__ = 'issue_user_tag' sqlalchemy.exc.InvalidRequestError: Table 'issue_user_tag

Re: [sqlalchemy] Single Table Inheritance with mult-column keys

2012-08-24 Thread Rob
Hi Michael, That does exactly what I was after (and I've learned a little bit more about sqalchemy!) Thank you very much for your help. On Thursday, 23 August 2012 19:13:27 UTC+1, Michael Bayer wrote: On Aug 23, 2012, at 10:04 AM, Rob wrote: Hi Michael, I have a similar (but subtly

Re: [sqlalchemy] Single Table Inheritance with mult-column keys

2012-08-23 Thread Rob
. (rather than bunging up this message, please see the attached file) I'd be really grateful if you could take a look and hopefully point me in the right direction. Many thanks, Rob On Wednesday, 17 August 2011 00:42:28 UTC+1, Michael Bayer wrote: On Aug 16, 2011, at 5:37 PM, Mike

[sqlalchemy] [R]edesign

2011-02-01 Thread Rob
necessarily be very limited in scope: it would not support table creation and only have a dialectical backing for MySQL. Many other components I could leave as stubs. In any case, I want to avoid design decisions that will limit future extensibility. Thanks! -- Rob -- You received this message because

[sqlalchemy] Reflected Tables and Session [and how to bind]

2010-02-12 Thread Rob
will need to be passed to an __init__ in the class above. Is there a strategy for dealing with this? Many thanks, Rob -- 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

[sqlalchemy] SqlSoup and joined-table inheritance

2010-02-09 Thread Rob
]) db.flush() A flush is required (at some point) to commit the data to the table, but for multiple inserts the method above is horribly slow. Am I missing something fundamental? Is there a faster/better (possibly correct!) way to do this? Many thanks, Rob -- You received this message because you

[sqlalchemy] Re: SqlSoup and joined-table inheritance

2010-02-09 Thread Rob
Thanks for your super-quick response Michael !! I have a feeling that (especially given that there are a number of foreign keys involved in this) I may be best off, as you suggest, using the mappings/reflected tables. Many thanks again, Rob On Feb 9, 11:17 pm, Michael Bayer mike

[sqlalchemy] multiple foreign keys to the same table

2008-08-23 Thread Rob
equated, locally mapped column pairs for primaryjoin condition 'call.caller_id = contact.id' on relation Call.caller. For more relaxed rules on join conditions, the relation may be marked as viewonly=True. Can someone tell me what I'm doing wrong, please? Thanks, Rob

[sqlalchemy] Re: multiple foreign keys to the same table

2008-08-23 Thread Rob
') }) did the trick. Thanks! On Aug 23, 8:58 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Aug 23, 2008, at 1:56 PM, Rob wrote: Hi, I'm using sqlalchemy 0.5 beta 3 and I am trying to have a Call object that contains two relations to a Contact object.  One is the callee and the other

[sqlalchemy] Modelling a complex(ish) many-to-many association with dates

2008-07-20 Thread Rob Cowie
the collection to be aware of existing indices, and not write a row for existing relationship (i think there is a pattern for this on the wiki). Am I biting of more than sa can chew? Should I implement this in some other, more app-specific way? Thanks in advance, Rob C

[sqlalchemy] Re: Modelling a complex(ish) many-to-many association with dates

2008-07-20 Thread Rob Cowie
. Regardless, I think the rest of your answer implies a custom solution is appropriate. Cheers, Rob C On Jul 20, 6:44 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Jul 20, 2008, at 1:22 PM, Rob Cowie wrote: I have a many-to-many relationship between 'Company' and 'Index', defined