Re: [sqlalchemy] trouble with a self-referential query and remote side population

2018-01-03 Thread Mike Bayer
didn't look close yet but you wouldn't want to have foreign() on a column that is a primary key column. should be on the opposite side of whatever refers to a primary key. On Wed, Jan 3, 2018 at 6:28 PM, Jonathan Vanasco wrote: > i've got a handful of bad data from some

[sqlalchemy] trouble with a self-referential query and remote side population

2018-01-03 Thread Jonathan Vanasco
i've got a handful of bad data from some edge cases and have been having trouble querying the data with sqlalchemy. i attached a SSCCE below. my cleanup script imports the model, extends `Main_Foo` with a new relationship, and creates 2 aliases. this selects the right rows (2 and 4) but the

Re: [sqlalchemy] Multiple inserts parameter inconsistency

2018-01-03 Thread Aubrey
Hello, I came across this while I was building an experimental project to get to grips with sqlalchemy. I wanted to only set some fields when inserting rows, but wanted to decouple the code that actually built the SQL from the decision logic, which led me to pass column references, which led

Re: [sqlalchemy] raise error on insert/update PK?

2018-01-03 Thread Tim Chen
Thanks so much! Really appreciate the example. On Wednesday, January 3, 2018 at 3:46:47 PM UTC-5, Mike Bayer wrote: > > On Wed, Jan 3, 2018 at 1:18 PM, Tim Chen > wrote: > > Let's say I'm using a uuid PK for my models with a ` server_default` set > to > >

Re: [sqlalchemy] Deleting rows from a table where row elements are found in a pandas.DataFrame

2018-01-03 Thread Jevgenij Kusakovskij
It is a list of dictionaries indeed. I will investigate this issue tomorrow. If something useful comes out or if I have any more questions, I will write back here. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please

Re: [sqlalchemy] raise error on insert/update PK?

2018-01-03 Thread Mike Bayer
On Wed, Jan 3, 2018 at 1:18 PM, Tim Chen wrote: > Let's say I'm using a uuid PK for my models with a ` server_default` set to > `gen_random_uuid()` (in PostgreSQL). Is there a way to ensure the > server_default value? I would like to catch any INSERT or UPDATE statements >

Re: [sqlalchemy] Deleting rows from a table where row elements are found in a pandas.DataFrame

2018-01-03 Thread Mike Bayer
On Wed, Jan 3, 2018 at 12:30 PM, Jevgenij Kusakovskij wrote: > Thank you for such a quick response! > > Tried your suggestions, but still getting the same error. > > And could it be caused by some data in the DataFrame being 'odd'? E.g. > Timestamp('2012-05-22 00:00:00')

Re: [sqlalchemy] Re: SQLAlchemy 1.2.0 released

2018-01-03 Thread Mike Bayer
On Wed, Jan 3, 2018 at 12:18 PM, Seth P wrote: > Perhaps this isn't the right place to ask, but do you know when > https://anaconda.org/conda-forge/sqlalchemy will be updated to 1.2.0? hm, I actually know nothing about where that comes from! sorry > > -- > SQLAlchemy - >

Re: [sqlalchemy] Building relatively complex dynamic queries in SQLAlchemy

2018-01-03 Thread Jonathan Vanasco
I have a few of these and generally use a variant of Simon's method where I wrap everything in a custom class. I stash all the requirements/options in the custom class instance, then invoke a `count()` or `paginated()` method that builds/stashes the core query and runs `count()` or `all()` on

[sqlalchemy] raise error on insert/update PK?

2018-01-03 Thread Tim Chen
Let's say I'm using a uuid PK for my models with a ` server_default` set to `gen_random_uuid()` (in PostgreSQL). Is there a way to ensure the server_default value? I would like to catch any INSERT or UPDATE statements that set the PK value and raise an error if possible. -- SQLAlchemy -

Re: [sqlalchemy] Deleting rows from a table where row elements are found in a pandas.DataFrame

2018-01-03 Thread Jevgenij Kusakovskij
Thank you for such a quick response! Tried your suggestions, but still getting the same error. And could it be caused by some data in the DataFrame being 'odd'? E.g. Timestamp('2012-05-22 00:00:00') assigned to col2. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper

[sqlalchemy] Re: SQLAlchemy 1.2.0 released

2018-01-03 Thread Seth P
Perhaps this isn't the right place to ask, but do you know when https://anaconda.org/conda-forge/sqlalchemy will be updated to 1.2.0? -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal,

Re: [sqlalchemy] Deleting rows from a table where row elements are found in a pandas.DataFrame

2018-01-03 Thread Mike Bayer
On Wed, Jan 3, 2018 at 11:21 AM, Jevgenij Kusakovskij wrote: > I feel bad bugging you with questions everyday, but it seems that I get them > answered here... Hope I am not abusing your hospitality. > > I would like to delete multiple rows from a table on a MS SQL Server. The >

[sqlalchemy] Deleting rows from a table where row elements are found in a pandas.DataFrame

2018-01-03 Thread Jevgenij Kusakovskij
I feel bad bugging you with questions everyday, but it seems that I get them answered here... Hope I am not abusing your hospitality. I would like to delete multiple rows from a table on a MS SQL Server. The rows to be deleted are given in a `pandas.DataFrame` object and there can be thousands

Re: [sqlalchemy] Building relatively complex dynamic queries in SQLAlchemy

2018-01-03 Thread Simon King
On Tue, Jan 2, 2018 at 11:59 PM, Nikola Jankovic wrote: > I have an API endpoint that handles searches from the frontend. A search can > have a dynamic amount of filters applied to it, including (1) sizes, (2) > colors, (3) price, and (4) category that are passed through query