Re: [PossibleSpam][5.0] Re: [sqlalchemy] Concise, Pythonic query syntax

2017-11-06 Thread Jones, Bryan
All, I've just updated the package to use the MIT license. Bryan On Mon, Nov 6, 2017 at 2:22 PM, Jones, Bryan <bjo...@ece.msstate.edu> wrote: > Chris, > > I'm open to BSD or MIT as well. Looking, I see that SQLAlchemy is > MIT-license, so I can re-license it to that. > &g

Re: [PossibleSpam][5.0] Re: [sqlalchemy] Concise, Pythonic query syntax

2017-11-06 Thread Jones, Bryan
Chris, I'm open to BSD or MIT as well. Looking, I see that SQLAlchemy is MIT-license, so I can re-license it to that. Bryan On Mon, Nov 6, 2017 at 12:25 PM, Chris Withers <ch...@withers.org> wrote: > Great looking library, shame about the license. > > You particularly attached t

Re: [sqlalchemy] Concise, Pythonic query syntax

2017-11-03 Thread Bryan Jones
://pythonic-sqlalchemy-query.readthedocs.io/en/latest/README.html Thanks to Mike for his feedback and encouragement to post this on PyPI. I've addressed the weaknesses he mentioned and added more features and tests. Comments and feedback are welcome. Enjoy! Bryan On Friday, June 16, 2017 at 4:54:36

[sqlalchemy] Re: Concise, Pythonic query syntax

2017-06-19 Thread Bryan Jones
for the feedback! Bryan On Thursday, June 15, 2017 at 3:11:47 PM UTC-5, Bryan Jones wrote: > > All, > > While working on my SQLAlchemy-based application, I noticed an opportunity > to provide a more concise, Pythonic query syntax. For example, > User['jack'].addresses produces a Que

[sqlalchemy] Concise, Pythonic query syntax

2017-06-15 Thread Bryan Jones
. I've attached the code, and a HTML document of the code with helpful hyperlinks. Bryan -- Bryan A. Jones, Ph.D. Associate Professor Department of Electrical and Computer Engineering 231 Simrall / PO Box 9571 Mississippi State University Mississippi State, MS 39762 http://www.ece.msstate.edu

[sqlalchemy] Explicit main table

2011-07-07 Thread Bryan
I'm having trouble telling an orm query which table is the main table when I only use a single column from the main table and it is wrapped up in an SQL function. It's almost like SqlAlchemy can't see that I am using a column from that table because it is inside of a function:: # -- Schema

[sqlalchemy] Re: Explicit main table

2011-07-07 Thread Bryan
Thanks, that worked. On Jul 7, 11:57 am, Michael Bayer mike...@zzzcomputing.com wrote: On Jul 7, 2011, at 2:16 PM, Bryan wrote: I'm having trouble telling an orm query which table is the main table when I only use a single column from the main table and it is wrapped up in an SQL

Re: [sqlalchemy] MySQL DATE_ADD function

2010-10-05 Thread Bryan Vicknair
On Tue, Oct 5, 2010 at 1:58 AM, Chris Withers ch...@simplistix.co.uk wrote: Are you looking for something database agnostic or something that just works for MySQL? If the latter, look at text: http://www.sqlalchemy.org/docs/core/tutorial.html#using-text If the former, then you'll want a

[sqlalchemy] Re: MySQL DATE_ADD function

2010-10-05 Thread Bryan
On Oct 5, 4:45 pm, Bryan Vicknair bryanv...@gmail.com wrote: I'm fine with a MySQL-only solution. The text construct is always the fallback, but I'm wondering if there is a way that I can use the attributes of my class for the column name, instead of just a string. My column names

[sqlalchemy] MySQL DATE_ADD function

2010-10-04 Thread Bryan
I'm having trouble converting this SQL into an ORM statement. DATE_ADD(datecol, INTERVAL(1 - DAYOFWEEK(datecol)) DAY) This is as far as I can get, which is basically nowhere. The second argument to date_add requires literal strings INTERVAL and DAY, but I also need to insert a function in the

[sqlalchemy] Checking internals of query object

2010-08-27 Thread Bryan
I am writing a function that adds particular columns and groupings to a query based on some options. I am trying to write some unit tests for the function, and would like to check that the correct columns are being added/grouped. Give a query like: q = session.query(Employee.firstName,

[sqlalchemy] Re: Checking internals of query object

2010-08-27 Thread Bryan
Bayer mike...@zzzcomputing.com wrote: On Aug 27, 1:24 pm, Bryan bryanv...@gmail.com wrote: I am writing a function that adds particular columns and groupings to a query based on some options.  I am trying to write some unit tests for the function, and would like to check that the correct

[sqlalchemy] Re: func type_ not being used

2010-08-04 Thread Bryan
Same behavior with 0.6.3. On Aug 3, 4:17 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Aug 3, 2010, at 5:00 PM, Bryan wrote: Python 2.5.4 MySQL python 1.2.3c1 sqlalchemy 0.5.2 just curious can you try with SQLA 0.6.3 ? Here is the actual code.  It references my object model

[sqlalchemy] Re: func type_ not being used

2010-08-04 Thread Bryan
, at 11:14 AM, Bryan wrote: Same behavior with 0.6.3. On Aug 3, 4:17 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Aug 3, 2010, at 5:00 PM, Bryan wrote: Python 2.5.4 MySQL python 1.2.3c1 sqlalchemy 0.5.2 just curious can you try with SQLA 0.6.3 ? Here is the actual code

[sqlalchemy] func type_ not being used

2010-08-03 Thread Bryan
This returns a Decimal type for c2, which is what I want: c1 = literal(5, type_=Numeric) c2 = func.sum(c1, type_=Numeric) This returns a Float type for c2, but I'm telling c1 that it is a Numeric. How can I get a decimal returned when using an if function? c1 = func.if_(Table.foo != None,

[sqlalchemy] Re: func type_ not being used

2010-08-03 Thread Bryan
(EmpTime.timeType) q = q.group_by(Account.code).group_by(TimeType.shortName) q = q.filter(EmpTime.day = start) q = q.filter(EmpTime.day = end) q = q.filter(EmpTime.jobId == jobId) labor = q.all() On Aug 3, 1:26 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Aug 3, 2010, at 2:56 PM, Bryan wrote

[sqlalchemy] Updating table w/ bindparam

2010-05-20 Thread Bryan
I know this has got to be simple. I am updating table1 in MySQL. u = table1.update() u.values(col1=bindparam('_col1'), col2=bindparam('_col2') ... updateVals = [ {'_col1': 5, '_col2': table1.col1 * 5} ] engine.execute(u, updateVals) I was expecting table1.col1 * 5 to show up as:

[sqlalchemy] Re: Updating table w/ bindparam

2010-05-20 Thread Bryan
provides. On May 20, 8:01 am, Conor conor.edward.da...@gmail.com wrote: On 05/20/2010 09:56 AM, Bryan wrote:I know this has got to be simple. I am updating table1 in MySQL. u = table1.update() u.values(col1=bindparam('_col1'), col2=bindparam('_col2') ... updateVals = [ {'_col1': 5, '_col2

[sqlalchemy] Re: Updating table w/ bindparam

2010-05-20 Thread Bryan
actual code doesn't modify the update object in place, sorry about the typo. On May 20, 8:41 am, Conor conor.edward.da...@gmail.com wrote: On 05/20/2010 10:28 AM, Bryan wrote: How about some sort of literal: table1.col1 * 5 (without the quotes) as the value of a bindparam?  So

[sqlalchemy] Re: Updating table w/ bindparam

2010-05-20 Thread Bryan
I see. Greatly appreciated. SA is amazing. On May 20, 9:09 am, Conor conor.edward.da...@gmail.com wrote: On 05/20/2010 10:53 AM, Bryan wrote: Including the expressing in the values() clause w/ a bindparam like in your second example did the trick.  I haven't checked the MySQL logs if I

[sqlalchemy] Override onupdate timestamp

2010-05-19 Thread Bryan
I have a table 'table', with a column, 'stamp', that has an onupdate clause onupdate=datetime.now. I am trying to update table.otherColumn, and I don't want table.stamp to be updated with the latest time. I saw one discussion about overriding onupdate here:

[sqlalchemy] Column type in select w/ if condition

2010-03-30 Thread Bryan
The underlying column returns a Decimal object when queried regularly, and when summed as follows: select([ mytable.c.hours ]) Decimal(1.0) select([ func.sum(mytable.c.hours) ]) Decimal(1.0) ...but when I sum it w/ an if statement, it returns a float: select([ func.sum(func.if_(True,

[sqlalchemy] Re: Column type in select w/ if condition

2010-03-30 Thread Bryan
That worked, thanks. On Mar 30, 7:40 am, Mariano Mara mariano.m...@gmail.com wrote: Excerpts from Bryan's message of Tue Mar 30 11:27:57 -0300 2010: The underlying column returns a Decimal object when queried regularly, and when summed as follows: select([ mytable.c.hours ])

[sqlalchemy] Can't append WHERE col IN to select object

2009-11-10 Thread Bryan
Trying to append this to a select object: WHERE jobId IN (SELECT id FROM job WHERE number=1) So I do this: query = select(Bunch of stuff including a `jobId` column) subq = select([job.c.id], job.c.number==1).as_scalar() query = query.where(query.c.jobId.in_(subq)) But that is not

[sqlalchemy] Re: Can't append WHERE col IN to select object

2009-11-10 Thread Bryan
On Nov 10, 12:46 pm, Michael Bayer mike...@zzzcomputing.com wrote: Bryan wrote: Trying to append this to a select object: WHERE jobId IN (SELECT id FROM job WHERE number=1) So I do this: query = select(Bunch of stuff including a `jobId` column) subq = select([job.c.id

[sqlalchemy] Re: Mapping select to Read-only reporting class

2009-10-26 Thread Bryan
it, it seemed to join my SELECT statement with the job table as a Cartesian product, because it didn't understand how to join my SELECT statement with the job table because there were no foreign keys defined. On Sep 14, 3:00 pm, Michael Bayer mike...@zzzcomputing.com wrote: Bryan wrote: I

[sqlalchemy] relation in object mapped to select statement?

2009-09-15 Thread Bryan
The following code models a simple system that tracks the transfer of construction tools between jobs. Equip (equipment) is transferred between Jobs via Shipments. Towards the end I attempt to map a class to a select statement in order to make reporting simple. Instead of dealing with sql to

[sqlalchemy] Mapping select to Read-only reporting class

2009-09-14 Thread Bryan
I want to abstract some ugly reporting SQL strings into a read-only object model. I have created an empty class, and then I map it to a select object that pulls some statistical information from the DB. The mapper is complaining that it can't assemble a primary key. I am only using this object

[sqlalchemy] Building an or_ filter in loop

2009-05-08 Thread Bryan
I can't figure out a clean way of adding a bunch of filter terms to a query in a loop joined by an OR clause. Successive calls to filter join the expressions by AND. I would like to do something like the following, but have the expressions joined by OR terms = ['apple', 'orange', 'peach'] q =

[sqlalchemy] Re: Building an or_ filter in loop

2009-05-08 Thread Bryan
That worked, thanks On May 8, 12:59 pm, Kyle Schaffrick k...@raidi.us wrote: On Fri, 8 May 2009 12:52:09 -0700 (PDT) Bryan bryanv...@gmail.com wrote: I can't figure out a clean way of adding a bunch of filter terms to a query in a loop joined by an OR clause.  Successive calls

[sqlalchemy] GUID creation causing foreign key errors

2009-03-10 Thread Bryan
The primary keys in my db are GUIDs, char(36). When I generate the GUID in python using the uuid module, everything works fine. But when I allow the db to generate the GUIDs I get foreign key errors when trying to save a new parent and child. A look at the SQL generated shows that the parent

[sqlalchemy] How to clarify ambiguous join

2009-03-09 Thread Bryan
), Time.day, Job.number, Account.code ) q = q.join(Job) q = q.join(Account) How can i tell sqlalchemy to join Job and Account to Time, and not to eachother? Bryan --~--~-~--~~~---~--~~ You received this message because you are subscribed

[sqlalchemy] Re: How to clarify ambiguous join

2009-03-09 Thread Bryan
, 1:12 pm, Michael Bayer mike...@zzzcomputing.com wrote: specify the join as an on condition: q.join(Time.account) q.join(Time.job) Bryan wrote: I have a table 'Time' that has many-to-1 relationships to tables 'Job' and 'Account'.  There is also a 1-to-many relationship between job

[sqlalchemy] Re: How to clarify ambiguous join

2009-03-09 Thread Bryan
Bayer mike...@zzzcomputing.com wrote: Bryan wrote: The join works great now.  Thanks. This query is actually being used for a subquery.  Table 'Time' also has a column 'employeeId', which translates to an orm attribute of 'emp'.  When I add Time.emp to the columns of this subquery, all

[sqlalchemy] Using a SQL function w/ strange syntax as default

2009-03-05 Thread Bryan
complains about invalid syntax when it encounters the USING part. How can I set this chain of functions as a default? Is there some sort of SQL literal function that I could use? I tried using the literal object, but it of course escapes whatever the value is which does not work. Bryan