Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-27 Thread Jeremy Flowers
*Well the printed oracle sql dialect now works correctly - when I hack it an replace the substitution variables for the literals like so in my SQL Editor:* == WITH j1(jobmst_id, jobmst_name, jobmst_prntid, jobmst_type, lvl) AS (SELECT jobmst.jobmst_id AS jobmst_id, jobmst.jobmst_name AS

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-27 Thread Jeremy Flowers
wrote: > >> OK, your original SQL works, will find the difference > >> > >> On Thu, Apr 26, 2018 at 5:32 PM, Mike Bayer <mike...@zzzcomputing.com> > wrote: > >>> Jeremy - > >>> > >>> This whole thread is based on an exact SQL

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-27 Thread Jeremy Flowers
But can you still do things like slice(0,5)? Struggling to get that to work atm... On Fri, Apr 27, 2018 at 2:48 PM, Simon King <si...@simonking.org.uk> wrote: > On Fri, Apr 27, 2018 at 12:57 PM, Jeremy Flowers > <jeremy.g.flow...@gmail.com> wrote: > > Right... >

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-27 Thread Jeremy Flowers
aa83e20de6229afe > 2a3600b648/lib/sqlalchemy/dialects/oracle/base.py#base.py-813 > > I suspect that it's not handling your CTE properly. I don't even know > what the right SQL syntax should be. > > At this point I would echo Mike's question: why can't you just use > "text()"

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-27 Thread Jeremy Flowers
SELECT * FROM ( SELECT A.*, rownum rn FROM ( SELECT * FROM J1 ORDER BY DISP_SEQ) A WHERE rownum <= 4) WHERE rn >= 3 This is the crazy type of syntax required... On Fri, Apr 27, 2018 at 5:12 PM, Jeremy Flowers <jeremy.g.flow...@gmail.c

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-27 Thread Jeremy Flowers
False else: for row in partial_results: print(row.items()) if offset == 4: more_results = False connection.close() On Fri, Apr 27, 2018 at 6:43 PM, Jeremy Flowers <jeremy.g.flow...@gmail.com> wrote: > Thanks. > > On Fri, Apr 27, 2018 at 6:08

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-27 Thread Jeremy Flowers
o be using here. > > Also set echo='debug' on create_engine which will log all the rows > coming back. > > On Fri, Apr 27, 2018 at 12:12 PM, Jeremy Flowers > <jeremy.g.flow...@gmail.com> wrote: > > Hah.. Seems Oracle ROWNUM starts from 1, not 0.. > > When yo

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-27 Thread Jeremy Flowers
s,type(partial_results), partial_results == [])) if partial_results == []: more_results = False else: for row in partial_results: print(row.items()) if offset == 4: more_results = False connection.close() On Fri, Apr 27, 2018 at 6:15 PM, Jeremy F

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-27 Thread Jeremy Flowers
Finish 3 C:\opt\tidalconversion> On Fri, Apr 27, 2018 at 4:12 PM, Jeremy Flowers <jeremy.g.flow...@gmail.com> wrote: > I'm thinking along these lines. But can't get it to work. > #!/usr/bin/env python > import sqlalchemy > from sqlalchemy import text, create_engine, column >

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-27 Thread Jeremy Flowers
in partial_results: print(row.items()) Getting TypeError: get_bind() got an unexpected keyword argument 's' Got idea from here... https://security.openstack.org/guidelines/dg_parameterize-database-queries.html - it's obviously wrong! On Fri, Apr 27, 2018 at 3:49 PM, Jeremy Flowers

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-27 Thread Jeremy Flowers
;si...@simonking.org.uk> wrote: > No, you'll need to convert that to the equivalent SQL. > > On Fri, Apr 27, 2018 at 3:14 PM, Jeremy Flowers > <jeremy.g.flow...@gmail.com> wrote: > > But can you still do things like slice(0,5)? Struggling to get that to > work > > atm.

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-27 Thread Jeremy Flowers
Hah.. Seems Oracle ROWNUM starts from 1, not 0.. When you select between 3 and 4 - nothing returns. There's an Oracle quirk... On Fri, Apr 27, 2018 at 5:03 PM, Jeremy Flowers <jeremy.g.flow...@gmail.com> wrote: > Have tried dropping session.execute and using connection.execut

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-27 Thread Jeremy Flowers
Ah right.. http://docs.sqlalchemy.org/en/latest/core/connections.html#sqlalchemy.engine.ResultProxy You can do fetchmany - and do a partial_results compare to empty list.. I see there is a next option too. So, it's a slightly different paradigm On Fri, Apr 27, 2018 at 3:14 PM, Jeremy Flowers

[sqlalchemy] Re: SQLACODEGEN + VSCODE + Intellisense not working.

2018-05-12 Thread Jeremy Flowers
Have posted on Stack Overflow here -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an

[sqlalchemy] Re: SQLACODEGEN + VSCODE + Intellisense not working.

2018-05-12 Thread Jeremy Flowers
Have recorded a video showcasing issue. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and

[sqlalchemy] Re: SQLACODEGEN + VSCODE + Intellisense not working.

2018-05-13 Thread Jeremy Flowers
I got some feedback on Stack Overflow that sounds promising.. Does SQLAlchemy by any chance use Doctstrings to indicated return types? Seems PyCharm Python IDE may have a work around for this? See:

[sqlalchemy] Re: SQLACODEGEN + VSCODE + Intellisense not working.

2018-05-13 Thread Jeremy Flowers
> > I'd say specifically for this part: > jobrow = session.query(Jobmst).filter(Jobmst.jobmst_id==job['jobmst_id']). first() That first method at the end... -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please

[sqlalchemy] Re: SQLACODEGEN + VSCODE + Intellisense not working.

2018-05-13 Thread Jeremy Flowers
I got some feedback on Stack Overflow that sounds promising.. Does SQLAlchemy by any chance use Doctstrings to indicated return types? Seems PyCharm Python IDE may have a work around for this? See: https://stackoverflow.com/questions/24684954/pycharm-type-hinting-of-class-fields-instance-variables

[sqlalchemy] Re: SQLACODEGEN + VSCODE + Intellisense not working.

2018-05-13 Thread Jeremy Flowers
I added PEP0526 code hint and that fixed it. jobrow = session.query(Jobmst).filter(Jobmst.jobmst_id==job['jobmst_id']).first() # type: Jobmst Is it feasible for the SQLAlchemy tool to correctly add these a the library level? It would be

[sqlalchemy] Re: SQLACODEGEN + VSCODE + Intellisense not working.

2018-05-11 Thread Jeremy Flowers
I've also been looking at here in the hope of finding a solution. I tried setting this in the VS Code (Version 1.23.1) 'User Settings' tab (File -> Preferences -> Settings) "python.autoComplete.extraPaths":

[sqlalchemy] Re: SQLACODEGEN + VSCODE + Intellisense not working.

2018-05-11 Thread Jeremy Flowers
Also tried this in extrapaths - no joy either: ${workspaceRoot} Per this thread <https://github.com/Microsoft/vscode-python/issues/39> On Saturday, 12 May 2018 00:32:40 UTC+1, Jeremy Flowers wrote: > > I've also been looking at here > <https://code.visualstudio.com/do

[sqlalchemy] SQLACODEGEN + VSCODE + Intellisense not working.

2018-05-11 Thread Jeremy Flowers
I have some code in VS Code... jobrow = session.query(Jobmst).filter(Jobmst.jobmst_id==job['jobmst_id']). first() Jobmst is imported from a single module I've created called tidal.py jobrow is an instance of Jobmst... But I can't select any of the columns. I've tried

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-26 Thread Jeremy Flowers
> > I think it must have been down to the imports.. > By changing code for imports to this, it seemed to fix it. import sqlalchemy from tidal import Jobmst from sqlalchemy import create_engine, literal, text from sqlalchemy.dialects import oracle from sqlalchemy.orm import Session, aliased,

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-26 Thread Jeremy Flowers
Does this need to be submitted as an error on Git somewhere? On Thu, Apr 26, 2018 at 10:29 PM, Jeremy Flowers <jeremy.g.flow...@gmail.com > wrote: > I can confirm. I copied and pasted Mike's Python verbatim, and got exactly > same issues with generated SQL > > On Thu, Apr 26

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-26 Thread Jeremy Flowers
) SEARCH DEPTH FIRST BY JOBMST_NAME SET DISP_SEQ SELECT j1.jobmst_id, j1.jobmst_name, j1.jobmst_prntid, j1.jobmst_type, j1.lvl FROM j1 ORDER BY DISP_SEQ So, the AS names are ok it seems... But, the SELECT should come after DISP_SEQ too On Thu, Apr 26, 2018 at 10:17 PM, Jeremy Flowers

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-26 Thread Jeremy Flowers
I can confirm. I copied and pasted Mike's Python verbatim, and got exactly same issues with generated SQL On Thu, Apr 26, 2018 at 10:21 PM, Jeremy Flowers <jeremy.g.flow...@gmail.com > wrote: > I hacked the parameterised query: > This works.. > WITH j1(jobmst_id, jobmst_name

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-26 Thread Jeremy Flowers
initely runs correctly, then > you look at the "bad SQL", and figure out exactly what is different. > "I think in my original, DISP_SEQ would still be in the resultset" > what does that mean in terms of the query? the query I gave you > should have had every element t

[sqlalchemy] SQLAlchemy UML class diagram.

2018-04-26 Thread Jeremy Flowers
One of the things I struggle with as a newcomer to Python from Java, is if I import a class from a namespace, I expect to find the code in that namespace. But I find namespace A includes namespace B, so you are forever chasing around in IDE's to get your head around the structures.. Case in

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-26 Thread Jeremy Flowers
*Mike I know what the problem is.* *The SQL emitted by SQLAlchemy is wrong!* This is why I get: *ORA-00923: FROM keyword not found where expected. *You only get error code when you try to execute the code - with first(), all(), slice() Look for the <- in the generated code (x4) This

Re: [sqlalchemy] Help resolving Could not determine join condition between parent/child tables on relationship error message

2018-02-08 Thread Jeremy Flowers
> > I reposted this on Stack Overflow - and solved my own question in this > instance with a bit of Google Kung Fu https://stackoverflow.com/questions/48666026/sqlalchemy-could-not-determine-join-condition-between-parent-child-tables-on-re/48672033#48672033 --

[sqlalchemy] Ways with SQLAlchemy ORM to get back some of the columns for a table

2018-02-08 Thread Jeremy Flowers
I've seen you can do things like this: fields = ['jobmst_type', 'jobmst_name'] print(session.query(Jobmst).options(load_only(*fields)).first()) But according to the documentation, you should be able to do something with Query values()

[sqlalchemy] Why does join() method not have join type as an argument?/Is left-join the default..

2018-02-09 Thread Jeremy Flowers
I've got a domain model out of sqlacodegen. I need to do a SQL a join between two tables, with no inferred foreign-keys in the database I'm working on. Consequently there isn't a relationship defined for the specific columns I need to join 1) I need a INNER JOIN for the first. 2) But later I

[sqlalchemy] Re: Register function example (perhaps) to remove tab, newline or carriage return from column.

2018-02-09 Thread Jeremy Flowers
'), Can you cast InstrumentedAttribute to a string and back? As it stands you get: AttributeError: Neither 'InstrumentedAttribute' object nor 'Comparator' object associated with Jobdtl.jobdtl_cmd has an attribute 'replace' On Friday, 9 February 2018 19:18:55 UTC, Jeremy Flowers wrote: > > I'm aw

Re: [sqlalchemy] Re: Why does join() method not have join type as an argument?/Is left-join the default..

2018-02-09 Thread Jeremy Flowers
ust didn't call the .join() method at all. > > Simon > > On Fri, Feb 9, 2018 at 4:52 PM, Jeremy Flowers > <jeremy.g...@gmail.com > wrote: > > I'm wondering if this is part of the secret sauce: > > http://docs.sqlalchemy.org/en/latest/orm/query.html#sqlalchemy.orm.join

[sqlalchemy] Register function example (perhaps) to remove tab, newline or carriage return from column.

2018-02-09 Thread Jeremy Flowers
I'm aware with Oracle I could probably do something like this: REPLACE(REPLACE(REPLACE(o.jobdtl_cmd, CHR(9), ''), CHR(10), ''), CHR(13), '') as COMMAND Is there a database agnostic way of doing this in SQLAlchemy? Would it be possible to provide a list of numbers, like 9,10,13, that would get

[sqlalchemy] Re: Why does join() method not have join type as an argument?/Is left-join the default..

2018-02-09 Thread Jeremy Flowers
I'm wondering if this is part of the secret sauce: http://docs.sqlalchemy.org/en/latest/orm/query.html#sqlalchemy.orm.join Also I guess cross-join may be another join type. JOIN is INNER by default.. https://stackoverflow.com/a/19646594/495157 On Friday, 9 February 2018 16:03:03 UTC, Jeremy

[sqlalchemy] Re: Register function example (perhaps) to remove tab, newline or carriage return from column.

2018-02-10 Thread Jeremy Flowers
I've not been able to get that version working. Tried % method to pass params into format a string. Also tried string,format() method with {} syntax. No joy. For example: @compiles(stripctrl) def stripctrl_default(element, compiler, **kw): args = list(element.clauses) return

[sqlalchemy] Re: Register function example (perhaps) to remove tab, newline or carriage return from column.

2018-02-09 Thread Jeremy Flowers
So I tried following along with this. 1) created a file called *custfunc.py* In it I placed this: from sqlalchemy.sql import expression from sqlalchemy.ext.compiler import compiles from sqlalchemy.types import String class stripctrl(expression.FunctionElement): type = String() name =

[sqlalchemy] Re: Register function example (perhaps) to remove tab, newline or carriage return from column.

2018-02-11 Thread Jeremy Flowers
I'm afraid it just doesn't work. I would think you have to import String too.. from sqlalchemy.types import String The only difference between your and my code, is i don't have a default and a sqlite.. I tried it as default, and oracle... not both. Also the custom function is in a separate

[sqlalchemy] Re: Ways with SQLAlchemy ORM to get back some of the columns for a table

2018-02-09 Thread Jeremy Flowers
, 9 February 2018 09:48:51 UTC, Jeremy Flowers wrote: > > I was thinking about this overnight.. > Do *values* relates specifically to inserts and updates, not > selects/deletes perhaps, which would correlate to SQL syntax. > If, it would make sense to indicate that in the docum

[sqlalchemy] Re: Ways with SQLAlchemy ORM to get back some of the columns for a table

2018-02-09 Thread Jeremy Flowers
ing wrong or not getting? On Thursday, 8 February 2018 20:29:45 UTC, Jeremy Flowers wrote: > > I've seen you can do things like this: > fields = ['jobmst_type', 'jobmst_name'] > print(session.query(Jobmst).options(load_only(*fields)).first()) > > But according to the documentatio

Re: [sqlalchemy] Re: Ways with SQLAlchemy ORM to get back some of the columns for a table

2018-02-09 Thread Jeremy Flowers
aining-friendly method you are looking for is probably > with_entities(): > > > http://docs.sqlalchemy.org/en/latest/orm/query.html#sqlalchemy.orm.query.Query.with_entities > > > Simon > > On Fri, Feb 9, 2018 at 11:52 AM, Jeremy Flowers > <jeremy.g...@gmail.com &g

Re: [sqlalchemy] Re: Ways with SQLAlchemy ORM to get back some of the columns for a table

2018-02-09 Thread Jeremy Flowers
And that can be simplified to: print(session.query() .with_entities(Jobmst.jobmst_type, Jobmst.jobmst_name) .first() ) On Friday, 9 February 2018 12:21:37 UTC, Jeremy Flowers wrote: > > Hi Simon. > Instead of using values(), I did this. > print(session.

[sqlalchemy] Re: Ways with SQLAlchemy ORM to get back some of the columns for a table

2018-02-09 Thread Jeremy Flowers
I was thinking about this overnight.. Do *values* relates specifically to inserts and updates, not selects/deletes perhaps, which would correlate to SQL syntax. If, it would make sense to indicate that in the documentation On Thursday, 8 February 2018 20:29:45 UTC, Jeremy Flowers wrote

[sqlalchemy] Re: Register function example (perhaps) to remove tab, newline or carriage return from column.

2018-02-10 Thread Jeremy Flowers
Hi Jonathan. Thanks for the heads up. I also subsequently wondered if the part of the right of the % was a tuple.. Have to read up a bit more about that... If so, then I'd possibly need the extra comma in the parentheses... """REPLACE(REPLACE(REPLACE(%s, CHR(9), ''), CHR(10), ''), CHR(13),

[sqlalchemy] Re: cx_oracle sqlalchemy query not working.

2018-07-05 Thread Jeremy Flowers
Out of curiosity did you pip install cx_oracle recently too? I am having issues with cx_oracle on a Amazon instance we stood up/installed today. Yet my Python code on an older copy of Python 3.6/SqlAlchemy/cx_oracle seem to work fine. My error relates to a message: "positional and named binds

[sqlalchemy] positional and named binds cannot be intermixed

2018-07-05 Thread Jeremy Flowers
Hi. I have a Python VM with SQLAlchemy and my Python code. It all works fine with: Python 3.6.5 SqlAlchemy 1.2.6 I believe when I installed Sqlalchemy ages ago, I used: pip install sqlalchemy. We are now trying to run our code off a newly setup Amazon instance to enable co-workers to use the

Re: [sqlalchemy] positional and named binds cannot be intermixed

2018-07-05 Thread Jeremy Flowers
41:49 UTC+1, Mike Bayer wrote: > > as mentioned in the other thread, omit cx_Oracle 6.4 from requirements: > > cx_oracle>=6.0.2,!=6.3,!=6.4 > > https://github.com/oracle/python-cx_Oracle/issues/199 > > > > On Thu, Jul 5, 2018 at 8:42 AM, Jeremy Flowers &g

Re: [sqlalchemy] positional and named binds cannot be intermixed

2018-07-05 Thread Jeremy Flowers
3,!=6.4 > > https://github.com/oracle/python-cx_Oracle/issues/199 > > > > On Thu, Jul 5, 2018 at 8:42 AM, Jeremy Flowers > > wrote: > > Hi. > > I have a Python VM with SQLAlchemy and my Python code. > > It all works fine with: > > Python 3.6.5 &g

[sqlalchemy] ORA-03135 and SqlAlchemy... Is there a design pattern to get around this?

2018-07-09 Thread Jeremy Flowers
Hi. We've recently ported a database to an Amazon cloud based instance.. Sporadically I am getting ORA-3135 errors. >From what I can tell here there may be some configuration parameters

[sqlalchemy] Re: ORA-03135 and SqlAlchemy... Is there a design pattern to get around this?

2018-07-09 Thread Jeremy Flowers
Thanks Jonathan - I'll take a look On Monday, 9 July 2018 22:09:57 UTC+1, Jonathan Vanasco wrote: > > http://docs.sqlalchemy.org/en/latest/core/pooling.html > > specifically: > > http://docs.sqlalchemy.org/en/latest/core/pooling.html#disconnect-handling-pessimistic > and > >

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-24 Thread Jeremy Flowers
ike...@zzzcomputing.com> wrote: > On Mon, Apr 23, 2018 at 4:35 PM, Jeremy Flowers > <jeremy.g.flow...@gmail.com> wrote: > > I've had a go at trying to adapt your code: > > > > import tidal > > from sqlalchemy import create_engine, Column > > from sqlalchem

[sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-23 Thread Jeremy Flowers
, not I want to include a column that is for the LVL per my original SQL code. How do I add ad-hoc columns to my CTE? On Thursday, 19 April 2018 23:20:10 UTC+1, Jeremy Flowers wrote: > > I take it you meant here: > > https://bitbucket.org/zzzeek/sqlalchemy/issues/3220/several-

[sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-23 Thread Jeremy Flowers
I'm assuimg you do something like define a Column . But how do you assign a literal or expression value to it? (1 or LVL+1 later) Is there a bind processor example I need? from sqlalchemy import

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-23 Thread Jeremy Flowers
> > The Session() object does not accept column objects within its > constructor, it looks like you are thinking of using the Query object. You are right, I was looking at the example here and I

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-23 Thread Jeremy Flowers
> > Is alias or mapping the correct construct if I want to select a subset of > the fields that SQLACODEGEN created? I sent you a Skype invite. I'd be interested in getting some training if you'd like to continue the chat via Skype. -- SQLAlchemy - The Python SQL Toolkit and Object

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-23 Thread Jeremy Flowers
On Monday, 23 April 2018 16:46:52 UTC+1, Jeremy Flowers wrote: > > Is alias or mapping the correct construct if I want to select a subset of >> the fields that SQLACODEGEN created? > > I sent you a Skype invite. I'd be interested in getting some training if > you'd like

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-23 Thread Jeremy Flowers
> > I'm also mysfified why connect() doesn't get shown as an method for engine > in Visual Studio. > Looked here

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-23 Thread Jeremy Flowers
I've had a go at trying to adapt your code: import tidal from sqlalchemy import create_engine, Column from sqlalchemy.dialects import oracle from sqlalchemy.orm import aliased from sqlalchemy.orm.session import sessionmaker from sqlalchemy.orm.query import Query from sqlalchemy.sql import select

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-23 Thread Jeremy Flowers
(I've literally got 18 tabs open looking at different parts of the docs ATM!) On Mon, Apr 23, 2018 at 5:29 PM, Jeremy Flowers <jeremy.g.flow...@gmail.com> wrote: > > > On Monday, 23 April 2018 16:46:52 UTC+1, Jeremy Flowers wrote: >> >> Is alias or mapping the

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-23 Thread Jeremy Flowers
I am beginning to thing this may be the way... http://docs.sqlalchemy.org/en/latest/orm/tutorial.html >>> stmt = text("SELECT name, id, fullname, password "... "FROM >>> users where name=:name")>>> stmt = stmt.columns(User.name, User.id, >>> User.fullname, User.password)SQL >>>

[sqlalchemy] Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-19 Thread Jeremy Flowers
I'm working on a system that has an underlying Oracle database... I was looking at this article here: https://oracle-base.com/articles/11g/recursive-subquery-factoring-11gr2 Can you do the equivalent of the Oracle WITH inside SQLAlchemy (I think this is also referred to as CTE in MS SQL Server

[sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-19 Thread Jeremy Flowers
I take it you meant here: https://bitbucket.org/zzzeek/sqlalchemy/issues/3220/several-small-issues-with-oracle-recursive I'll look into this more tomorrow. Thanks for your time. On Thursday, 19 April 2018 23:14:23 UTC+1, Jonathan Vanasco wrote: > > almost everything in `func` is just standard sql

[sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-19 Thread Jeremy Flowers
I suspect this may be trying to do something similar perhaps.. http://docs.sqlalchemy.org/en/latest/_modules/examples/materialized_paths/materialized_paths.html But I don't understand this part. Specifically where 'c' comes from: ancestors = relationship("Node", viewonly=True,

[sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-19 Thread Jeremy Flowers
I'm thinking 'c' must be some sort of column shorthand -- 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] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-19 Thread Jeremy Flowers
Thanks for the feedback. CTE handles the WITH side of things. But how about depth/breadth first? On Thursday, 19 April 2018 22:28:00 UTC+1, Jonathan Vanasco wrote: > > In the example you pointed to, `c` are the columns of an object created by > `alias()` > > `secondary` was created as an

[sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-19 Thread Jeremy Flowers
Also in the materialised path example , what is What is unnest doing? Is it something like converting 1 row into many? -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-25 Thread Jeremy Flowers
Mike. Thanks for the Datacamp link you emailed me. If I understand your point earlier the references to the full table class as well as the selected columns were causing the

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-26 Thread Jeremy Flowers
Having gone thru the Datacamp videos I now see where my select to get columns was unnecessary. So, I now have code that is practically identical to Mike's post. But it still errors out: import tidal from sqlalchemy import create_engine, Column from sqlalchemy.dialects import oracle from

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-26 Thread Jeremy Flowers
.jobmst_id AS jobmst_id, j1.jobmst_name AS jobmst_name, j1.jobmst_prntid AS jobmst_prntid, j1.jobmst_type AS jobmst_type, j1.lvl AS lvl FROM j1 ORDER BY DISP_SEQ) On Thu, Apr 26, 2018 at 7:24 PM, Jonathan Vanasco <jvana...@gmail.com> wrote: > > On Thursday, April 26, 2018 at 1:59:02 PM U

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-26 Thread Jeremy Flowers
What's needed is a method on the class that compiles the statement, to implicitly bind params. Here is the type: sqlalchemy.dialects.oracle.cx_oracle.OracleCompiler_cx_oracle/ I want to add slice to the end too, to paginate results. More bound params! -- SQLAlchemy - The Python SQL Toolkit

Re: [sqlalchemy] Re: Recursive Queries in SQLAlchemy (WITH clause/SEARCH BY depth/breadth)

2018-04-26 Thread Jeremy Flowers
http://sqlalche.me/e/cd3x On Thu, Apr 26, 2018 at 8:16 PM, Jeremy Flowers <jeremy.g.flow...@gmail.com> wrote: > Since the SQL injects parameters into the string, this doesn't seem to > work. > eg: > A value is required for bind parameter 'param_1' > > WITH j