[sqlalchemy] Re: Joinedload from child to parent in a joined table relationship

2020-11-03 Thread Alex Collins
messier application code. On Tuesday, November 3, 2020 at 8:57:18 AM UTC-3:30 Alex Collins wrote: > Trying to configure a set of relationships to all be joined loaded and the > particular relationship structure doesn’t seem to want to join. I have a > one-to-many relationship where

[sqlalchemy] Joinedload from child to parent in a joined table relationship

2020-11-03 Thread Alex Collins
Trying to configure a set of relationships to all be joined loaded and the particular relationship structure doesn’t seem to want to join. I have a one-to-many relationship where the many is the child in joined table inheritance. The foreign key to my source table is on the polymorphic child

[sqlalchemy] Re: Custom secondary relation with composite primary keys

2020-04-26 Thread Alex Plugaru
that already has a lot of data. On Sunday, April 26, 2020 at 10:43:46 AM UTC-7, John Walker wrote: > > Hello Alex, > > This is super old, so I don't have a lot of hope. > But I'm wondering if you could explain a line in your example text. > > I'm trying to figure out if I need

[sqlalchemy] Re: Correct and easy method to copy tables from MySQL to Oracle

2020-02-03 Thread Alex Hill
table, I used it and I am satisfied. Just be careful when copying from Oracle to MySQL as their isn't a MySQL equivalent to the NUMBER data type. This solution requires sqlalchemy. On Saturday, February 1, 2020 at 10:58:06 PM UTC+2, Alex Hill wrote: > > Hello everyone, > >

[sqlalchemy] Correct and easy method to copy tables from MySQL to Oracle

2020-02-01 Thread Alex Hill
Hello everyone, I apologize if this question has been answered before, i've done some of my of searching and solution testing before coming here. I've even created a thread on stackoverflow

[sqlalchemy] Receiving this error: sqlalchemy.exc.DBAPIError: (pyodbc.Error) ('HYC00', u'[HYC00] [Microsoft][ODBC SQL Server Driver]Optional feature not implemented (0) (SQLBindParameter)')

2019-05-17 Thread Alex Net
Hello! I have been writing code that would allow me to read from an Excel sheet and writing it in a MS SQL Database. The code was functioning well, meaning it was running and writing all cells until it got to cell E,23 , where it crashes. Column E is called DueDate, and the first 22 cells print

Re: [sqlalchemy] Unexplained SELECT Being Issued

2018-12-01 Thread Alex Rothberg
this is caused by another attribute on EmployeeRecord: s.add(er) # this then blows up: e.records = [er] On Saturday, December 1, 2018 at 10:08:08 PM UTC-5, Mike Bayer wrote: > > On Sat, Dec 1, 2018 at 9:55 PM Mike Bayer > wrote: > > > > On Sat, Dec 1, 2018 at 9:21 PM A

[sqlalchemy] Unexplained SELECT Being Issued

2018-12-01 Thread Alex Rothberg
I set up the DB: from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class Employee(Base): __tablename__ = 'employee' id = Column(Integer, primary_key=True) class EmployeeRecord(Base):

Re: [sqlalchemy] How should I eagerly load a property from multiple levels of a self-referential table?

2018-10-26 Thread Alex Wang
Ah, ok. I thought defaultload() meant use whatever was originally specified in the relationship(). That helps a lot! On Friday, October 26, 2018 at 12:34:53 PM UTC-4, Mike Bayer wrote: > > On Fri, Oct 26, 2018 at 12:10 PM Alex Wang > wrote: > > > > I ended up n

Re: [sqlalchemy] How should I eagerly load a property from multiple levels of a self-referential table?

2018-10-26 Thread Alex Wang
like what you suggested and use that? And just to make sure, selectinloads should be the right choice for this kind of nested collection, right? Thanks! On Thursday, October 25, 2018 at 6:54:53 PM UTC-4, Mike Bayer wrote: > > On Thu, Oct 25, 2018 at 4:21 PM Alex Wang > > wrote:

[sqlalchemy] How should I eagerly load a property from multiple levels of a self-referential table?

2018-10-25 Thread Alex Wang
Hi all! I'm trying to write a small script to interface with a database controlled by a third-party application, and I'm not sure the way I set up eager loading is right. The code I have looks something like the following: from sqlalchemy.ext.declarative import declarative_base from

[sqlalchemy] Creating Sub Object with out inserting into Base Table

2018-10-23 Thread Alex Rothberg
I have added a new sub class to my model hierarchy. I would like to instantiate it however there will be cases where the base object / row already exists. I tried to solve this by passing in the user object to the StaffUser but it looks like sqla still tried to INSERT into the User table

Re: [sqlalchemy] Controlling table dependency for flushing

2018-10-11 Thread Alex Rothberg
of the relationships to None. For example if I cease to have all of fund, department and title, then the FundTitle is None. If i assign that to the Employee it then clears all of the other (overlapping) fks. On Wednesday, October 10, 2018 at 8:28:39 PM UTC-4, Mike Bayer wrote: > > O

Re: [sqlalchemy] Controlling table dependency for flushing

2018-10-10 Thread Alex Rothberg
department_id, fund_id), > (FundTitle.title_id, FundTitle.department_id, > FundTitle.fund_id) > ), > ) > > > ft1 = FundTitle(title=t1, department=d1, fund=f1) > e1 = Employee(fund_title=ft1) > > e.g. a simple association object pattern.

Re: [sqlalchemy] Controlling table dependency for flushing

2018-10-10 Thread Alex Rothberg
I not have to mark one Model as dependent on the other? Or is that implied by the order of the list? On Wednesday, October 10, 2018 at 1:36:09 PM UTC-4, Mike Bayer wrote: > > On Wed, Oct 10, 2018 at 1:32 PM Alex Rothberg > wrote: > > > > Well the other way doesn't quite work a

Re: [sqlalchemy] Controlling table dependency for flushing

2018-10-10 Thread Alex Rothberg
Well the other way doesn't quite work as if I mark none of the columns as foreign in the primary join, sqla then assumes / guesses all of them are. Let me test with passive. On Wed, Oct 10, 2018, 13:30 Mike Bayer wrote: > On Wed, Oct 10, 2018 at 1:27 PM Alex Rothberg > wrote: > >

Re: [sqlalchemy] Controlling table dependency for flushing

2018-10-10 Thread Alex Rothberg
ise load issue is because without passive_deletes, it has to > load the collection to make sure those objects are all updated. > passive_deletes fixes, now you just have a warning. or use the unit > of work recipe which is more direct. > On Wed, Oct 10, 2018 at 1:15 PM Alex Ro

Re: [sqlalchemy] Controlling table dependency for flushing

2018-10-10 Thread Alex Rothberg
wrote: > > On Wed, Oct 10, 2018 at 12:56 PM Alex Rothberg > wrote: > > > > let me get that. in the meantime, what are your thoughts on just > removing the view only from the original relationship and then using an > explicit primary join where none of the

Re: [sqlalchemy] Controlling table dependency for flushing

2018-10-10 Thread Alex Rothberg
:25 PM UTC-4, Alex Rothberg wrote: > > Is it possible to specific a non viewonly relationship in which I have a > primary join specified in which none of the fk's are marked "foreign"? ie > where I can mark the relationship dependancy but it wont set any columns? > It loo

Re: [sqlalchemy] Controlling table dependency for flushing

2018-10-10 Thread Alex Rothberg
ll columns are fk if none are specified as foreign? On Wednesday, October 10, 2018 at 11:56:49 AM UTC-4, Alex Rothberg wrote: > > So one minor issue and one big issue with that solution: > 1. minor issue, I now get these: SAWarning: relationship '' will copy > column to column

Re: [sqlalchemy] Controlling table dependency for flushing

2018-10-10 Thread Alex Rothberg
rt seeing: sqlalchemy.exc.InvalidRequestError: 'Employee._ft_for_dependency' is not available due to lazy='raise' On Wednesday, October 10, 2018 at 9:57:55 AM UTC-4, Mike Bayer wrote: > > On Tue, Oct 9, 2018 at 6:45 PM Alex Rothberg > wrote: > > > > Okay with some small tweaks to your original code, I am

Re: [sqlalchemy] Controlling table dependency for flushing

2018-10-09 Thread Alex Rothberg
er 9, 2018 at 12:20:30 PM UTC-4, Mike Bayer wrote: > > On Tue, Oct 9, 2018 at 10:44 AM Alex Rothberg > wrote: > > > > In looking at what you wrote doesn't this cause an fk violation (it does > for me): > > 2018-10-08 10:18:38,760 INFO sqlalchemy.engine.bas

Re: [sqlalchemy] Controlling table dependency for flushing

2018-10-09 Thread Alex Rothberg
I should say, I didn't run your exact code but essentially that ordering is what is causing my issues with my code in that the new fund_title is inserted after the new employee. On Tue, Oct 9, 2018 at 10:44 AM Alex Rothberg wrote: > In looking at what you wrote doesn't this cause an

Re: [sqlalchemy] Controlling table dependency for flushing

2018-10-09 Thread Alex Rothberg
: > On Sun, Oct 7, 2018 at 7:11 PM Alex Rothberg wrote: > > > > Okay so I investigated / thought about this further. The issue is that > while I do have a relationship between the various models, some of the > relationships are viewonly since I have overlapping fks. > > >

Re: [sqlalchemy] Controlling table dependency for flushing

2018-10-07 Thread Alex Rothberg
master=file-view-default#unitofwork.py-111) > > > > > > Looking at that code made me wonder whether you've set any particular > > cascade options on your relationship; I'm not sure if cascade options > > affect the dependency calculation. > > > > Simo

Re: Migrating PEP-435 Enums

2018-09-24 Thread Alex Rothberg
This seems to work / provide a good template of how to get that info: https://github.com/dw/alembic-autogenerate-enums On Monday, September 24, 2018 at 5:19:39 PM UTC-4, Alex Rothberg wrote: > > and is there an easy way to progrmatically get the name of the enum from > the model field

Re: Migrating PEP-435 Enums

2018-09-24 Thread Alex Rothberg
have an ENUM type.Your request for an > "op.alter_column()" directive is basically asking for those issues to > be done. I'm on a long term search for code contributors who can > work on that stuff, ENUM is going to be very hard to work front to > back in all cases. > > &g

Migrating PEP-435 Enums

2018-09-24 Thread Alex Rothberg
Assuming that I am using the PEP-435 enum feature in SQLA, e.g.: class InvitationReason(str, enum.Enum): ORIGINAL_ADMIN = "ORIGINAL_ADMIN" FIRM_USER = "FIRM_USER" ... reason = db.Column(db.Enum(InvitationReason), nullable=False) and I want to add / change the values in the enum. I

Re: [sqlalchemy] Setting join_depth on Query

2018-09-20 Thread Alex Rothberg
Is there anyway to set the join_depth on the options, or do I just have to write that myself with a for loop? On Thursday, September 20, 2018 at 8:50:59 AM UTC-4, Mike Bayer wrote: > > On Wed, Sep 19, 2018 at 5:26 PM Alex Rothberg > wrote: > > > > Following up on > h

[sqlalchemy] Setting join_depth on Query

2018-09-19 Thread Alex Rothberg
Following up on https://groups.google.com/forum/#!searchin/sqlalchemy/join_depth%7Csort:date/sqlalchemy/WstKKbEFaRo/hL910npaBQAJ and https://stackoverflow.com/questions/4381712/how-do-you-dynamically-adjust-the-recursion-depth-for-eager-loading-in-the-sqlal, is there any way to set the

Re: [sqlalchemy] Controlling table dependency for flushing

2018-09-17 Thread Alex Rothberg
, Simon King wrote: > > In that case can you show us the code that is causing the problem? > On Fri, Sep 14, 2018 at 2:55 PM Alex Rothberg > wrote: > > > > I am not generating any IDs myself and I already have relationships > between the models. > > > > O

Re: [sqlalchemy] Controlling table dependency for flushing

2018-09-14 Thread Alex Rothberg
I am not generating any IDs myself and I already have relationships between the models. On Friday, September 14, 2018 at 4:33:08 AM UTC-4, Simon King wrote: > > On Thu, Sep 13, 2018 at 10:50 PM Alex Rothberg > wrote: > > > > Is it possible to hint at sqla the order in

[sqlalchemy] Controlling table dependency for flushing

2018-09-13 Thread Alex Rothberg
Is it possible to hint at sqla the order in which it should write out changes to the DB? I am having issues in which I add two new objects to a session, a and b where a depends on b, but sqla is flushing a before b leading to an fk issue. I can solve this a few ways: explicitly calling flush

Re: [sqlalchemy] ForeignKeyConstraint using Forward Declared Model

2018-09-04 Thread Alex Rothberg
syntax for ForeignKeyConstraint rather than just the string syntax? On Tuesday, September 4, 2018 at 10:43:13 PM UTC-4, Alex Rothberg wrote: > > You're right the error I posted is coming from somewhere else. I am trying > to get a stripped down example. In the meantime, it looks like w

Re: [sqlalchemy] ForeignKeyConstraint using Forward Declared Model

2018-09-04 Thread Alex Rothberg
You're right the error I posted is coming from somewhere else. I am trying to get a stripped down example. In the meantime, it looks like when I add the additional fk constraint, model.__mapper__.get_property(property_name) on a different model starts failing. File "/Users/alex/.

[sqlalchemy] ForeignKeyConstraint using Forward Declared Model

2018-09-04 Thread Alex Rothberg
Is it possible to set up a `ForeignKeyConstraint` that uses a class not yet declared? ie is there a way to use either the lambda or string syntax to forward declare the fk constrains? Neither works for me. Using strings yields: File "", line 2, in join_condition File "/Us

Re: [sqlalchemy] Setting many to many collection with secondary relationship when having only pk to one of the models.

2018-08-23 Thread Alex Rothberg
: > > On Wed, Aug 22, 2018 at 5:41 PM, Alex Rothberg > wrote: > > I am using an association model / table to represent a many to many > > relationship: > > > > class Geography(db.Model): > > > > id = > >

[sqlalchemy] Setting many to many collection with secondary relationship when having only pk to one of the models.

2018-08-22 Thread Alex Rothberg
I am using an association model / table to represent a many to many relationship: class Geography(db.Model): id = ... class Fund(db.Model): id = ... geography_associations = db.relationship( lambda: FundGeographyAssociation, back_populates="fund",

[sqlalchemy] Remote side backpopulates

2018-08-21 Thread Alex Rothberg
Is there any way to declare a "remote side" backpopulates? i.e. where I declare a relationship on class A to appear only on class B? I would like the relationship only to be available on the remote class but I do not want to / cannot modify the code for the remote class. For example: class

[sqlalchemy] sqlacodegen 2.0.0 released

2018-05-20 Thread Alex Grönholm
After a quiet period of 3 years, I've now made a new major release. This release fixes a huge number of bugs and supports the latest SQLAlchemy and latest Python versions as well. It also adds support for Geoalchemy2. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper

[sqlalchemy] Re: Guidance regarding nested session usage

2017-08-12 Thread alex
Thank you very much for the guidance Jonathan and Mike. I've implemented nesting counting on my context manager and turned off autocommit and subtransactions. It looks like it's working well! Alex On Wednesday, August 9, 2017 at 5:14:09 PM UTC+1, al...@withplum.com wrote: > > Hey, &

[sqlalchemy] Guidance regarding nested session usage

2017-08-09 Thread alex
can immediately see a problem where if I query for an object before passing it to an action, then use the context manager, all the work done on querying is lost since the object state is expired on rollback. I'd appreciate any advice/input. Best, Alex -- SQLAlchemy - The Python SQL Toolki

[sqlalchemy] Composite column with null property

2017-05-11 Thread alex
Hello, I have a Money composite column, comprised of an `amount` (Decimal) and a `currency` (String). Sometimes the amount needs to be NULL, but then I get an instance of Money(None, 'GBP'). Is there any way to force the composite to return None in this case? Thanks, Alex -- SQLAlchemy

[sqlalchemy] Re: Custom secondary relation with composite primary keys

2017-05-04 Thread Alex Plugaru
It worked! Thanks a lot! On Friday, 28 April 2017 18:49:40 UTC-7, Alex Plugaru wrote: > > Hello, > > There are 3 tables: `*Account*`, `*Role*`, `*User*`. Both `*Role*` and ` > *User*` have a foreign key `*account_id*` that points to `*Account*`. > > A user can have

[sqlalchemy] Re: Custom secondary relation with composite primary keys

2017-05-04 Thread Alex Plugaru
, user_id=u.id), # dict(account_id=a.id, role_id=m_role.id, user_id=u.id), # ]) # session.execute(i) # re-fetch user from db u = session.query(User).options(joinedload('roles')).first() for r in u.roles: print(r) Thank you! Alex. On Friday, 28 April 2017 18:49:40 UTC-7, Alex Plugaru wrote

[sqlalchemy] Custom secondary relation with composite primary keys

2017-04-28 Thread Alex Plugaru
/43690944/sqalchemy-custom-secondary-relation-with-composite-primary-keys Hope it's ok. Thank you for your help, Alex. -- 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

[sqlalchemy] Multi-table deletes with PostgreSQL

2016-09-16 Thread Alex Grönholm
I'm attempting to do a multi-table delete against PostgreSQL (psycopg2) with the following query: session.query(ProductionItem).\ filter(Project.id == ProductionItem.project_id, Project.code.in_(projects), ProductionItem.external_id.is_(None)).\

Re: [sqlalchemy] Rolling back the session in a context manager

2016-07-16 Thread Alex Grönholm
15.07.2016, 16:55, Mike Bayer kirjoitti: On 07/15/2016 07:49 AM, Alex Grönholm wrote: The documentation provides the following example snippet for using sessions within a context manager: so, back when I started putting "examples" in those docs, the idea was like, "hey, her

[sqlalchemy] Rolling back the session in a context manager

2016-07-15 Thread Alex Grönholm
The documentation provides the following example snippet for using sessions within a context manager: @contextmanagerdef session_scope(): """Provide a transactional scope around a series of operations.""" session = Session() try: yield session session.commit()

Re: [sqlalchemy] SQLAlchemy 1.0.12 use inner JOIN instead of LEFT OUTER JOIN

2016-04-26 Thread Alex Dev
Thank you for your quick answer Mike. Le mardi 26 avril 2016 00:28:10 UTC+2, Mike Bayer a écrit : > > > > well this usage above is wrong. You can't have contains_eager() and > joinedload() along the same paths at the same time like that. Also, > chaining joinedload() from contains_eager() is

[sqlalchemy] SQLAlchemy 1.0.12 use inner JOIN instead of LEFT OUTER JOIN

2016-04-25 Thread Alex Dev
Hello, I have a broken query when migrating from SQLAlchemy 0.9.4 to 1.0.12. It seems to be linked to a behavioral change in the ORM (http://docs.sqlalchemy.org/en/rel_1_0/changelog/migration_10.html#right-inner-join-nesting-now-the-default-for-joinedload-with-innerjoin-true) Here is

Re: [sqlalchemy] Modeling single FK to multiple tables

2016-03-28 Thread Alex Hall
That would certainly work. :) Would that offer any benefits over pyodbc, since I wouldn't have the mapping (which was taking all the time I was spending with SA)? On 3/25/16, Mike Bayer <clas...@zzzcomputing.com> wrote: > > > On 03/25/2016 05:20 PM, Alex Hall wrote: >>

Re: [sqlalchemy] Modeling single FK to multiple tables

2016-03-25 Thread Alex Hall
qlite db), then use automap to map classes to > those tables. > > Simon > > On Mon, Mar 21, 2016 at 3:12 PM, Alex Hall <ah...@autodist.com> wrote: > >> Wow, thanks guys, especially for the sample code! I'm trying to use >> the example (and fully understan

Re: [sqlalchemy] Modeling single FK to multiple tables

2016-03-21 Thread Alex Hall
. On 3/17/16, Mike Bayer <clas...@zzzcomputing.com> wrote: > > > On 03/17/2016 03:11 PM, Alex Hall wrote: >> Hello all, >> It seems like I can't go a day without running into some kind of wall. >> This one is a conceptual one regarding foreign keys. I have to

Re: [sqlalchemy] Re: Outer joins?

2016-03-19 Thread Alex Hall
That would be the simplest. Having something so inefficient just bugs me. :) I'm using MSSQL, so limit() works. Would yield_per() help here, or is that for something different? Even if it didn't help local memory, but just kept the load on the DB server down, that would be good. On 3/16/16,

[sqlalchemy] joins instead of filters remove attributes of results

2016-03-19 Thread Alex Hall
Hello all, I'm running a different query than yesterday. Before, I had something like: items = session.query(itemTable, attachmentTable, attachmentTextTable, assignmentTable, attributeTable, attributeValueTable, attributeValueAssignmentTable, vendorTable)\ .filter(attachmentTable.itm_id ==

[sqlalchemy] Defining relationships (was: joins instead of filters remove attributes of results)

2016-03-18 Thread Alex Hall
wrote: > On Wed, Mar 16, 2016 at 1:07 PM, Alex Hall <ah...@autodist.com> wrote: > >> Hello all, >> I'm running a different query than yesterday. Before, I had something >> like: >> >> items = session.query(itemTable, attachmentTable, attachmentTextTable, >>

Re: [sqlalchemy] Re: Outer joins?

2016-03-16 Thread Alex Hall
> On Mar 16, 2016, at 03:23, Jonathan Vanasco wrote: > > The database design you have is less than perfect. I didn't make it, I came in long after it had been set up and now have to work with it. I can't re-do anything. They did it this way so that, for instance, a

Re: [sqlalchemy] Re: Outer joins?

2016-03-15 Thread Alex Hall
Thanks guys. I'm using automap, but I'm not completely sure how much that gives me for free. Yes, these tables are big, and the resulting set would be worrying large (potentially 5*20, and that's without the attributes and attachments, plus their assignment and values tables). I've switched to

[sqlalchemy] Outer joins?

2016-03-15 Thread Alex Hall
Hi all, I need to pull data from a bunch of tables, and I *think* outer joins are the way to do it. However, I can't find much on SA's support for outer joins. What I'm trying to do is pull all items from the Items table, as well as associated attachments and attributes if an item is tied to

Re: [sqlalchemy] Re: Adding 'where' to query

2016-03-14 Thread Alex Hall
Thanks for the clarification. I'm suddenly getting no results at all when I add this filter, but at least now I know I'm doing the syntax right. Never a dull moment. :) On 3/14/16, Jonathan Vanasco wrote: > >> >> .filter(t1.c1=='hello', and_(t3.c1=='world')) >> > > The

[sqlalchemy] Re: Adding 'where' to query

2016-03-14 Thread Alex Hall
, but filter is the obvious solution to most of my question. On 3/14/16, Alex Hall <ah...@autodist.com> wrote: > Hi all, > I had a link that was a great intro to querying, but of course, I > can't find it now. I need to add a couple conditions to my query. In > SQL,

[sqlalchemy] Adding 'where' to query

2016-03-14 Thread Alex Hall
Hi all, I had a link that was a great intro to querying, but of course, I can't find it now. I need to add a couple conditions to my query. In SQL, it might look like this: select * from t1 join t2 on t1.c1==t2.c1 join t3 on t3.c1==t1.c1 where t1.c1 = 'hello' and t3.c3 = 'world' The joins I

Re: [sqlalchemy] reflection fails on table with name in all caps

2016-03-14 Thread Alex Hall
lename__ = "VENDR" > PVVNNO = Column(String, primary_key=True) > > metadata.reflect(e, only=desiredTables, extend_existing=True) > assert 'VENDR' in metadata.tables > > base.prepare() > > assert VENDR.DATA > > sess = Session(e) > print sess.query(V

Re: [sqlalchemy] reflection fails on table with name in all caps

2016-03-14 Thread Alex Hall
ey=True) > > __table_args__ = {"extend_existing": True} > > that tells reflection to add new data to this Table object even though > it already exists. > > > On 03/14/2016 09:24 AM, Alex Hall wrote: >> Thanks for that. Somehow, I'm getting the same error as before--th

Re: [sqlalchemy] reflection fails on table with name in all caps

2016-03-14 Thread Alex Hall
d" / "Integer" combination above is just an example. > > Then do the automap as you've done. At the end, if it worked, > Base.classes.VENDR should be the same class as the VENDR class above. > > > On 03/11/2016 05:09 PM, Alex Hall wrote: >> Sorry, do you me

Re: [sqlalchemy] reflection fails on table with name in all caps

2016-03-11 Thread Alex Hall
t; > On 03/11/2016 04:14 PM, Alex Hall wrote: >> Ah, you're right. Every other table I've used in this database has had >> a key, and I didn't even notice that this VENDR table lacks one. That >> explains the mystery! Thanks. >> >> Now to map this table. I've read

Re: [sqlalchemy] reflection fails on table with name in all caps

2016-03-11 Thread Alex Hall
owever, I don't know if this would still work with automapping. On 3/11/16, Mike Bayer <clas...@zzzcomputing.com> wrote: > ah. does VENDR have a primary key? it won't be mapped if not. > > what's in base.classes.keys() ? base.classes['VENDR'] ? > > > > > > > On

Re: [sqlalchemy] reflection fails on table with name in all caps

2016-03-11 Thread Alex Hall
? This is the only table in the CMS to have a name in all caps, but I need to access it to look up manufacturer details for items. On 3/11/16, Mike Bayer <clas...@zzzcomputing.com> wrote: > > can you look in metadata.tables to see what it actually reflected ? > > > > > >

Re: [sqlalchemy] reflection fails on table with name in all caps

2016-03-11 Thread Alex Hall
That's weird: the name I see is exactly what I've been using, "VENDR". All caps and everything. I tried using lowercase, just to see what it would do, but it failed. On 3/11/16, Mike Bayer <clas...@zzzcomputing.com> wrote: > > > On 03/11/2016 09:39 AM, Alex Hall wrote:

[sqlalchemy] reflection fails on table with name in all caps

2016-03-11 Thread Alex Hall
Hello list, Finally, a pure SA question from me. I'm using Automap and the "only" keyword to automap a subset of the tables in our CMS database. This has worked perfectly thus far. Now, though, it's failing on a specific table, and the only difference I can see is that this table's name is in all

Re: [sqlalchemy] Re: Ways of processing multiple rows with same ID?

2016-03-10 Thread Alex Hall
What I'm doing, and sorry for not explaining further, is making a CSV file of data. Each row is a row in my results, or would be if I were just selecting from products. Having to select from attributes as well is where I'm having problems. Each product can have multiple attributes, and each

[sqlalchemy] Ways of processing multiple rows with same ID?

2016-03-10 Thread Alex Hall
Hi list, I'm not sure how to explain this, so let me know if I lose you. I have the same products database as yesterday, but I've just learned that product attributes are stored in their own tables. A product can have many attributes (size, color, weight, etc), and each attribute value is in a

[sqlalchemy] Re: properties of query results if names overlap?

2016-03-09 Thread Alex Hall
. On 3/9/16, Alex Hall <ah...@autodist.com> wrote: > Hi all, > Just a quick question: what does SA do if names overlap? For example, > in assignmentTable, there's a column called itm_id. In > attachmentTable, there's also a column called itm_id, and there's one > in itemTable

Re: [sqlalchemy] Re: Select * but apply distinct to one column

2016-03-09 Thread Alex Hall
learned something from all this. Thanks again for the help, guys. On 3/9/16, Jonathan Vanasco <jonat...@findmeon.com> wrote: > > On Wednesday, March 9, 2016 at 3:02:05 PM UTC-5, Alex Hall wrote: >> >> Fair enough, thanks. I didn't realize it was such a complex task;

[sqlalchemy] properties of query results if names overlap?

2016-03-09 Thread Alex Hall
Hi all, Just a quick question: what does SA do if names overlap? For example, in assignmentTable, there's a column called itm_id. In attachmentTable, there's also a column called itm_id, and there's one in itemTable as well. If I combine these in a kind of join, as in: results =

Re: [sqlalchemy] Re: Select * but apply distinct to one column

2016-03-09 Thread Alex Hall
Fair enough, thanks. I didn't realize it was such a complex task; I figured it was just a matter of passing an argument to distinct() or something equally easy. Speed isn't a huge concern, so I suppose I could get around this by storing the item numbers I find and then checking that the row I'm

[sqlalchemy] Select * but apply distinct to one column

2016-03-09 Thread Alex Hall
Hi all, I want to select * from a table, getting all columns. However, the only rows I want are where the item number is distinct. I've got: items = session.query(itemTable)\ .distinct()\ .limit(10) But that doesn't apply "distinct" to just item_number. I'm not the best with SQL in general or I'd

[sqlalchemy] Re: Bulk Insert Broken for Polymorphism?

2016-02-29 Thread Alex Hewson
myself with the added complexity. Cheers, Alex. On Monday, February 29, 2016 at 10:38:22 PM UTC, Alex Hewson wrote: > > Hello All, > > I'm trying to use the new bulk_save_objects() to improve performance on > bulk inserts, and have run into a problem. If bulk_save_objects() is

[sqlalchemy] Bulk Insert Broken for Polymorphism?

2016-02-29 Thread Alex Hewson
Hello All, I'm trying to use the new bulk_save_objects() to improve performance on bulk inserts, and have run into a problem. If bulk_save_objects() is used to save objects of a polymorphic class.. 1. They are created correctly in the DB, with polymorphic type column populated

Re: [sqlalchemy] MSSQL ProgrammingError with aggregate functions

2016-02-24 Thread Alex Lowe
'), different_column]).alias() q4 = sqlalchemy.select([q3.c.left_string, func.sum(q3.c.different_column)]).group_by(q3.c.left_string) sql_engine.execute(q4).fetchall() On Wednesday, 24 February 2016 09:26:59 UTC-6, Mike Bayer wrote: > > > > On 02/24/2016 10:13 AM, Alex Lowe wr

[sqlalchemy] MSSQL ProgrammingError with aggregate functions

2016-02-24 Thread Alex Lowe
at it does). c.session.execute( str(qq.selectable.compile(compile_kwargs={'literal_binds': True})) ).fetchall() If anyone can explain to me what I'm doing wrong and how to fix it, I'd be extremely grateful. Thanks, Alex -- You received this message because you are subscribed to the Google Groups &

Re: [sqlalchemy] connected using pyodbc; how to hook that to SA?

2016-02-19 Thread Alex Hall
;dbms_ver" attribute on the > pyodbc connection that you are creating in your custom creator function. > This is where it gets used: > > https://github.com/ibmdb/python-ibmdbsa/blob/master/ibm_db_sa/ibm_db_sa/base.py#L481 > > Simon > > On Fri, Feb 19, 2016 at 5:00 PM, Alex Hall

Re: [sqlalchemy] connected using pyodbc; how to hook that to SA?

2016-02-19 Thread Alex Hall
URL as > "db2+pyodbc://". Does that make any difference? > > On Fri, Feb 19, 2016 at 4:20 PM, Alex Hall <ah...@autodist.com> wrote: > >> Thanks. I tried both, and triedother variations including or excluding >> the module name as a prefix (ibm_db_sa.db2.

Re: [sqlalchemy] connected using pyodbc; how to hook that to SA?

2016-02-19 Thread Alex Hall
ibmdb/python-ibmdbsa/blob/master/ibm_db_sa/setup.py > > I would guess that you want to end up with the DB2Dialect_pyodbc class, > which means you should use db2.pyodbc:// or ibm_db_sa.pyodbc:// > > Simon > > > On Fri, Feb 19, 2016 at 3:33 PM, Alex Hall <ah...@autodist.co

Re: [sqlalchemy] connected using pyodbc; how to hook that to SA?

2016-02-19 Thread Alex Hall
ish flashbacks to my "has no attribute" error last week for the same object. But at least this is a different one; I'll count it as a good thing! On 2/19/16, Simon King <si...@simonking.org.uk> wrote: > On Fri, Feb 19, 2016 at 2:38 PM, Alex Hall <ah...@autodist.com> wrote: &g

[sqlalchemy] connected using pyodbc; how to hook that to SA?

2016-02-19 Thread Alex Hall
As the subject says, I am connected to our iSeries through straight pyodbc. That seems to run perfectly. Now, is there a way to use SA with that connection? When I use "ibm_db_sa+pyodbc://..." I get the exact same error I was getting when using ibm_db directly. Using pyodbc, I can specify the

[sqlalchemy] OT: basic ibm_db script hangs while connecting (wasreflection taking a very long time?)

2016-02-17 Thread Alex Hall
ru...@konk.org> wrote: > On Tue, Feb 16, 2016 at 04:02:08PM -0500, Alex Hall wrote: >> Great; I was hoping you wouldn't say that. :) I've been through them >> many, many times, trying to get the connection working. I've gone from >> error to error, and thought I had

Re: [sqlalchemy] Re: reflection taking a very long time?

2016-02-16 Thread Alex Hall
; On 02/16/2016 03:37 PM, Alex Hall wrote: >> I tried that, hoping for a bit more insight into the problem. However, >> unless I'm doing something wrong, I don't even get any queries. I get >> my own print statements, then the script tries to connect and hangs. >> I'v

Re: [sqlalchemy] Re: reflection taking a very long time?

2016-02-16 Thread Alex Hall
, and sure enough, it hangs on that line. On 2/16/16, Mike Bayer <clas...@zzzcomputing.com> wrote: > turning on echo=True inside create_engine() will show you what queries > are emitted as they occur so you can see which ones are taking long > and/or hanging. > > > On 02/16/2016 0

[sqlalchemy] Re: reflection taking a very long time?

2016-02-16 Thread Alex Hall
, the connection starts up and the script hangs. I'm no closer to solving this, and would love to hear anyone's thoughts, but at least I know that my thought of blaming reflect/automap is likely incorrect. On 2/16/16, Alex Hall <ah...@autodist.com> wrote: > Hi list, > Sorry for all the

[sqlalchemy] reflection taking a very long time?

2016-02-16 Thread Alex Hall
Hi list, Sorry for all the emails. I've determined that my script is actually connecting to the 400's test database. At least, a print statement placed just after the create_engine call is printing, so I guess we're good there. What I'm running into now is unresponsiveness when I try to reflect

Re: [sqlalchemy] Pyodbc.Connection has no attribute 'dbms_ver'?

2016-02-16 Thread Alex Hall
l knocking on its door. On 2/16/16, Michal Petrucha <michal.petru...@konk.org> wrote: > On Tue, Feb 16, 2016 at 10:27:40AM -0500, Alex Hall wrote: >> I have pyodbc 3.0.10, ibm_db_sa 0.3.2, and ibm_db 2.0.6. I'm also >> talking to people on the ibm_db list, and they s

Re: [sqlalchemy] Pyodbc.Connection has no attribute 'dbms_ver'?

2016-02-16 Thread Alex Hall
he object in “connection.connection” is a > pyodbc.Connection and doesn’t have a “dbms_ver” attribute. > > Note that there are at least 3 packages that could be involved here: > > pyodbc (https://pypi.python.org/pypi/pyodbc) > > ibm_db (https://pypi.python.org/pypi/ibm_db/) > > i

Re: [sqlalchemy] Pyodbc.Connection has no attribute 'dbms_ver'?

2016-02-15 Thread Alex Hall
what I can do about it, it looks like this dbms_ver property is definitely in the latest ibm_db_sa version. Am I getting this from the wrong place, or confusing this with a different package somehow? I *must* be missing something obvious. On 2/15/16, Alex Hall <ah...@autodist.com>

Re: [sqlalchemy] Pyodbc.Connection has no attribute 'dbms_ver'?

2016-02-15 Thread Alex Hall
off track with this? On 2/15/16, Alex Hall <ah...@autodist.com> wrote: > Thanks guys. I've checked the version I'm using, and it reports that > ibm_db_sa.__version__ is '0.3.2'. I have both ibm_db_sa and ibm_db > installed. Should I remove ibm_db and rely only on ibm_db_sa instead? > I

Re: [sqlalchemy] Pyodbc.Connection has no attribute 'dbms_ver'?

2016-02-15 Thread Alex Hall
y.a...@gmail.com> wrote: > Try to use ibm_db_sa 0.3.2 instead, apparently you are using the previous > version. dbms_ver is a feature specific of native ibm_db version of which > not available in pyodbc. > > https://pypi.python.org/pypi/ibm_db_sa/0.3.2 > > > Salam, > > -Jaimy

[sqlalchemy] Pyodbc.Connection has no attribute 'dbms_ver'?

2016-02-12 Thread Alex Hall
Hello list, I've configured a DSN to a test version of my work's AS400 and I seem to be able to connect just fine (Yes!) I'm now running into a problem when I try to ask for a list of all tables. The line is: dbInspector = inspect(dbEngine) The traceback is very long, and I can paste it if you

Re: [sqlalchemy] Connecting to AS400 with SQLAlchemy fails

2016-02-12 Thread Alex Hall
<michal.petru...@konk.org> wrote: > On Thu, Feb 11, 2016 at 01:16:03PM -0500, Alex Hall wrote: >> I've done more research on this topic. There's a lot out there about >> using MSSQL with SA, but next to nothing about using ibm_db_sa or >> specifying drivers. >&

Re: [sqlalchemy] Connecting to AS400 with SQLAlchemy fails

2016-02-11 Thread Alex Hall
nnect installed on your > machine. > > Salam, > > -Jaimy > On Feb 11, 2016 01:50, "Alex Hall" <ah...@autodist.com> wrote: > >> Hello list, >> I sent this to the ibm_db list yesterday, but no one has responded >> yet. Since it's as much ibm_db

  1   2   3   4   >