Someone wrote a server that blindly executes SQL strings? Oy. Google around for
why that is a terrible idea.
--
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
My 2c about table design (not SQLA): I would suggest having a child with
just id, a parent table with just id and child_id (foreign key to
child.id), and then store additional "versioned" data in separate
parent_history and child_history tables that have foreign keys only to
their respective
In relationship(), foreign_keys refers to the field in the source table,
not the destination.
--
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
I don't have a well-formulated question, but reading PEP 557
(https://www.python.org/dev/peps/pep-0557/) made me wonder if SQLAlchemy
declarative models would/should in some way be Python 3.7 data classes.
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
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,
Apologies if I missed something, but does SQLAlchemy (1.2.0?) support the new
Postgres 10 identity keyword
(https://blog.2ndquadrant.com/postgresql-10-identity-columns/)?
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code,
You're naming both tables 'parent_table'. Perhaps that is messing things up?
--
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
Perfect. Thank you!
On Friday, June 30, 2017 at 5:41:33 PM UTC-4, Mike Bayer wrote:
>
>
> from sqlalchemy import Column, String, Integer, create_engine
> from sqlalchemy.orm import Session
> from sqlalchemy.ext.declarative import declarative_base
> from sqlalchemy import event
>
> Base =
Jun 30, 2017 at 4:31 PM, Seth P <set...@outlook.com >
> wrote:
> > Is there a way (when using declarative) to specify that all the columns
> of a
> > table should use quote=False without specifying it explicitly for each
> > column?
>
> Easiest is just to call
Is there a way (when using declarative) to specify that all the columns of
a table should use quote=False without specifying it explicitly for each
column?
I've tried setting __table_args__ = { 'quote_schema': False, 'quote': False
}, but that just affects the schema and table name, not the
On Monday, October 17, 2016 at 3:58:36 PM UTC-4, Mike Bayer wrote:
>
> that error is there right now because we don't emit the "col IS NULL"
> SQL within that section of the persistence code.
>
> took me a long time to find the history on this because I thought it had
> been discussed but looks
I realize that the orm really wants/needs a table to have a primary key:
http://docs.sqlalchemy.org/en/rel_1_1/faq/ormconfiguration.html?#how-do-i-map-a-table-that-has-no-primary-key
Alas I have to deal with an existing table with no primary key. That said,
it does have a unique constraint on a
On Monday, October 17, 2016 at 11:24:43 AM UTC-4, Mike Bayer wrote:
>
> However, I don't see how the ordered attributes fixes anything in terms
> of mixins. If a mixin wants its columns at the beginning, or the end,
> all of that can be upended by the presence of other mixins and those
>
On a related note, is there something like after_create events for indexes
and sequences? There doesn't seem to be.
--
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
On Sunday, October 16, 2016 at 10:09:00 AM UTC-4, Mike Bayer wrote:
>
>
>
> The simplest way is probably to set the creation order of the column to
> be at the top:
>
> col = Column(...)
> col._creation_order = -10
Great. I will use _creation_order. Thanks.
By the way, in view of PEP 520
I have a mixin of the following form
class MyMixin(object):
idx = sa.Column(sa.Integer, sa.Sequence('idx_seq', schema=???,
optional=True), primary_key=True)
...
I would like the sequence to have the same schema as the table into which
MyMixin will be mixed. I realize I could make idx
ike...@zzzcomputing.com>
Sent: Monday, October 3, 2016 5:54 PM
Subject: Re: [sqlalchemy] Feedback appreciated
To: <sqlalchemy@googlegroups.com>
On 10/03/2016 05:21 PM, Seth P wrote:
>
>
> On Friday, September 30, 2016 at 7:09:09 PM UTC-4, Mike Bayer wrote:
>
> the bin
On Friday, September 30, 2016 at 7:09:09 PM UTC-4, Mike Bayer wrote:
>
> the bind_expression() hook is here to allow you to re-render the
> expression. assuming value-bound bindparam() objects (e.g. not like
> you'd get with an INSERT or UPDATE usually), the value should be present
> and you
On Thursday, September 29, 2016 at 9:45:24 AM UTC-4, Mike Bayer wrote:
>
> you can add your own types to do these things also, especially
> read-only, just make any subclass of UserDefinedType and apply whatever
> result-row handling is needed for how cx_Oracle is returning the data.
>
> The
On Wednesday, September 28, 2016 at 5:43:04 PM UTC-4, Mike Bayer wrote:
>
> looks incredibly difficult. I'm not really about to have the resources
> to work with a type that awkward anytime soon, unfortunately. If it
> could be made to be a drop-in for 1.1's ARRAY feature, that would be
>
On Wednesday, September 28, 2016 at 10:16:20 AM UTC-4, Mike Bayer wrote:
>
>
> So illustrating VARRAY round trip on cx_oracle is the first step.
>
It looks like cx_Oracle supports reading varrays, but supports writing them
only as column literals, not as bound parameters. The following code
Oops, I missed that this is an UPDATE rather than an INSERT. Setting the
missing columns to None probably isn't what you want.
On Wednesday, September 28, 2016 at 9:08:00 AM UTC-4, Seth P wrote:
>
> Can't you include the missing columns in your dictionary with None values?
>
--
You
On Friday, August 23, 2013 at 3:52:54 PM UTC-4, Konsta Vesterinen wrote:
>
>
>
> On Friday, August 23, 2013 1:52:41 AM UTC+3, Michael Bayer wrote:
>
>
>> 2. ScalarListType vs. Postgresql ARRAY ? same/better? should SLT use
>> ARRAY on a PG backend ?
>>
>
> Hmm I'm not sure about this yet.
Can't you include the missing columns in your dictionary with None values?
--
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
Thanks. I guess my confusion is that the example at
http://docs.sqlalchemy.org/en/latest/core/tutorial.html#executing-multiple-statements
uses an array of dictionaries, not of unlabeled tuples. Meanwhile I ended
up using Oracle's sqlldr, which seems to get the job done, though is much
more
The answer to this is probably RTFM, but I can't figure it out.
Suppose I have a declarative model of the form
class MyModel(Model):
idx = sa.Column(sa.Integer, primary_key=True)
c1 = sa.Column(sa.Float)
c2 = sa.Column(sa.Integer)
...
c10 = sa.Column(sa.Float)
And a list of
The documentation for DateTime,
http://docs.sqlalchemy.org/en/latest/core/type_basics.html?highlight=datetime#sqlalchemy.types.DateTime,
states
Parameters:*timezone* – boolean. If True, and supported by the backend,
will produce ‘TIMESTAMP WITH TIMEZONE’. For backends that don’t support
FWIW, this sounds similar to the problems you and I had (separately) a
couple of years ago:
https://groups.google.com/forum/#!topic/sqlalchemy/kv7BqWZr9KQ
https://groups.google.com/forum/#!topic/sqlalchemy/k_9ZGI-e85E
On Monday, September 12, 2016 at 5:39:37 PM UTC-4, Thierry Florac wrote:
>
> I
Has anyone written a SQLAlchemy dialect for kdb+/q? I realize q isn't
exactly SQL, but I figure if it's possible to write a dialect for Pandas
tables (https://bitbucket.org/zzzeek/calchipan) it should be possible to do
so for q.
--
You received this message because you are subscribed to the
order first. So it would be of
limited use for there to be an ordering under @declared_attr.
On 08/25/2016 02:46 PM, Seth P wrote:
> I was just bitten by this issue. Is it still the case that there is no way to
> specify the order of two columns declared in a mixin using @declared_attr?
I was just bitten by this issue. Is it still the case that there is no way to
specify the order of two columns declared in a mixin using @declared_attr?
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop
that has a
(unique) ForeignKey to A.)
On Wednesday, July 13, 2016 at 2:06:55 PM UTC-4, Mike Bayer wrote:
>
>
>
> On 07/13/2016 01:04 PM, Seth P wrote:
> > Thank you, as always, for the quick and detailed response.
> >
> > With the join to the subquery that's o
to the function, i.e.
join_to_min_a(q,
field_to_join_to_A_id).
On Wednesday, July 13, 2016 at 12:16:52 PM UTC-4, Mike Bayer wrote:
>
>
>
> On 07/13/2016 02:29 AM, Seth P wrote:
> > [Apologies for posting an incomplete version of this post earlier.
> > Please ignore it.]
> >
&g
Actually, taking a closer look, the sql generated for query 5 doesn't look
correct (or at least not what I want), since it isn't joining max_a_id with
anything.
On Wednesday, July 13, 2016 at 2:29:34 AM UTC-4, Seth P wrote:
>
> [Apologies for posting an incomplete version of this post e
[Apologies for posting an incomplete version of this post earlier. Please
ignore it.]
If B has a ForeignKey (and relationship) to A (e.g. B.a_id -> A.id), then I
can write query(B.b_num).join(A) without specifying the condition, and
SQLAlchemy will figure out the join automatically. [See query
Apologies if this is documented and I missed it.
If B has a ForeignKey (and relationship) to A (e.g. B.a_id -> A.id), then I
can write query(B.b_num).join(A) without specifying the condition, and
SQLAlchemy will figure out the join automatically. [See query 0 in the code
below.]
It will
Got it, thanks!
--
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 to this group, send email to
this properly.
Thanks in advance,
Seth
--
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 to this group, send email
Thanks Mike,
But...is there no way to set this behavior directly on the
relationship()? The whole point there is to be lazy ;)
Seth
On Saturday, May 10, 2014 7:59:33 PM UTC-7, Michael Bayer wrote:
session.query(Parent).options(defaultload(“children”).load_only(“cheap_column))
or really
relationship without the specific call within
the query().So unless you maybe ran those options into every Query
unconditionally, or something. I’d look to see how big a deal it is to
just be explicit on this one.
On May 14, 2014, at 1:39 PM, Seth seediff...@gmail.com javascript:
wrote
it to happen and how. It
likely would require some subclassing and possibly monkey patching.
On May 12, 2014, at 8:23 PM, Seth P spad...@gmail.com javascript:
wrote:
pymssql produces the same results as pyodbc. So it looks like a SQL Server
issue.
On Monday, May 12, 2014 8:06:08 PM UTC
be virtually
instantaneous.
Any thoughts?
Thanks,
Seth
import sqlalchemy as sa
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
import time
engine = sa.create_engine('mssql+pyodbc://Compustat/Compustat')
session = sessionmaker(bind=engine
Forgot to mention that I'm running SQLAlchemy 0.9.4 on 64-bit Python 3.4.0
on Windows.
On Monday, May 12, 2014 3:48:44 PM UTC-4, Seth P wrote:
After tracking down some extreme slowness in loading a one-to-many
relationship (e.g. myobject.foobars), I seem to have isolated the issue
://stackoverflow.com/questions/1171166/how-can-i-profile-a-sqlalchemy-powered-application/1175677#1175677
On May 12, 2014, at 3:48 PM, Seth P spad...@gmail.com javascript:
wrote:
After tracking down some extreme slowness in loading a one-to-many
relationship (e.g. myobject.foobars), I seem
, parameterized_runtime))
On Monday, May 12, 2014 6:40:48 PM UTC-4, Michael Bayer wrote:
On May 12, 2014, at 6:33 PM, Seth P spad...@gmail.com javascript:
wrote:
Is it possible that the (primary key index (which is a composite index
that begins with gvkey, and is the only index on the table) isn't being
to plug in parameters client-side. I presume not trivial to add to
SQLAlchemy? I don't see such an option for pyodbc.
On Monday, May 12, 2014 7:09:08 PM UTC-4, Seth P wrote:
Yep, it's not a SQLAlchemy issue. The following code demonstrates the
problem with direct pyodbc access.
import pyodbc
Fair enough. I'll take a look at pymssql, though I suspect it may be a SQL
Server rather than a driver issue.
On Monday, May 12, 2014 7:50:03 PM UTC-4, Michael Bayer wrote:
On May 12, 2014, at 7:35 PM, Seth P spad...@gmail.com javascript:
wrote:
Looks like other people have encountered
pymssql produces the same results as pyodbc. So it looks like a SQL Server
issue.
On Monday, May 12, 2014 8:06:08 PM UTC-4, Seth P wrote:
Fair enough. I'll take a look at pymssql, though I suspect it may be a SQL
Server rather than a driver issue.
On Monday, May 12, 2014 7:50:03 PM UTC-4
and not it's expensive_column.
Thanks,
Seth
--
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 to this group, send email
is not provided in the type_._compiler_dispatch() call from
TypeCompiler.process() in line 266 of compiler.py. The end of the traceback
is below.
I'm using SQLAlchemy 0.9.4, Python 3.4.0, and alchy 0.11.2.
Thanks,
Seth
...
C:\Python34\lib\site-packages\sqlalchemy\sql\visitors.py
Of course you are right. My problem code was basically the PythonEnum class
in https://groups.google.com/d/topic/sqlalchemy/5yvdhl9ErMo/discussion.
Deleting the *(m.name for m in enum_class), from the __init__ call seems
to have fixed the problem.
Thanks again.
Seth
On Monday, May 5, 2014 3
Apologies if I'm missing this is the docs somewhere, but I can't figure it
out. Suppose I have a many-to-many relationship between A and B, and that
I'd like have the various B's that a particular A points to ordered by
B.ordinal (i.e. in the examples below, I'd like A.bs to be sorted to
Just noticed that I had a typo, where I wrote order_by=b.ordinal rather
than order_by=b.order. But changing it to order_by=b.order still gives:
AttributeError: 'RelationshipProperty' object has no attribute 'order'
--
You received this message because you are subscribed to the Google Groups
'
object has no attribute 'order'. Is it possible to somehow specify order_by
so that the a.bs are automatically sorted by b.order?
Thanks!
Seth
from sqlalchemy import Column, Integer, ForeignKey, create_engine
from sqlalchemy.orm import create_session, relationship, backref
from
Thank you. This was very helpful.
One non-trivial thing that stumped me for a while is that if B is derived
from a B_base using joined-table inheritance, and the order variable is in
the base table B_base, then it seems one must include B_base explicitly --
as highlighted below.
from
, February 27, 2014 9:26:31 PM UTC-5, Michael Bayer wrote:
On Feb 27, 2014, at 9:23 PM, Seth P spad...@gmail.com javascript:
wrote:
Thank you. This was very helpful.
One non-trivial thing that stumped me for a while is that if B is derived
from a B_base using joined-table inheritance
session.commit() # UPDATE
session.close()
Thanks,
Seth
--
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
problem, the recipe fixes if you just say this:
class InexactFloat(TypeDecorator):
impl = Float
def compare_values(self, x, y):
return bool(x == y)
On Nov 19, 2013, at 8:30 PM, Michael Bayer
mik...@zzzcomputing.comjavascript:
wrote:
On Nov 19, 2013, at 8:10 PM, Seth
know I won't be accessing the related objects, I'd much rather load with
lazy='select' (so as not to load the related objects). Is this possible?
Thanks,
Seth
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To unsubscribe from this group and stop
D'oh! I did, though for some reason it didn't occur to me that I could
specify .override(lazyload('points')) to override the relationship's
default lazy='subquery'. Works like a charm. Thank you.
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To
'; tables have more than one foreign key constraint relationship
between them. Please specify the 'onclause' of this join explicitly.
Thanks,
Seth
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To unsubscribe from this group and stop receiving
Thank you.
On Wed, Jul 24, 2013 at 5:51 PM, Michael Bayer mike...@zzzcomputing.comwrote:
its a mapper arg called inherit_condition: __mapper_args__ =
{inherit_condition: id==A.id}
On Jul 24, 2013, at 3:42 PM, Seth P spadow...@gmail.com wrote:
The code below produces the error message
that favors the current behavior?
Thanks,
Seth
from sqlalchemy import Column, Integer, String, ForeignKey, create_engine
from sqlalchemy.ext.declarative.api import declarative_base
from sqlalchemy.orm import sessionmaker, scoped_session, relationship,
backref
from history_meta import VersionedMixin
)
result, [u'BBB']. Is this a bug, or is the query malformed?
In the second query, adding a seemingly gratuitous join with D fixes the
problem. And as the third query shows, replacing C by an aliased version
also fixes the problem. So whatever is going on seems rather subtle.
Thanks,
Seth
from
Yesterday I managed to get working all my 1 to 1 inserts. I was only
missing the following properties on the child and parent classes:
parent = Parent()
child = Child()
parent.child=child
child.parent=parent
--
You received this message because you are subscribed to the Google Groups
Hi Mike,
Thanks for your email. You are right. And actually, I read that
article two months ago and keeps coming back to me like haunting.
Does not matter how many python books I have, it is just so easy to
say but so hard to migrate my mind to python.
Anyway, I'll keep trying.
I still want to say
Hey,
I fixed problem #1.
Since I am not the first java - spring - hibernate developer migrating
to the python wold, nor the last..., here goes what I learned from
this:
Object properties cannot be private (cannot start with _ or __ ) for
SQLAlchemy to find them.
I do not know the exceptions to
Hi Mike,
Thank you very much for replying to my post. I really appreciate it.
I agree that the init of the classes may have something to do with the
problem.
Maybe the way we are defining the attributes does not allow to
SQLAlchemy table
wrappers to view the attributes' values?
What confuses me
Here goes the variables' parent class
#===
# Variable quantities with units
# Written by Konrad Hinsen hin...@cnrs-orleans.fr
# with contributions from Greg Ward
# last revision: 2007-5-25
# Revised for SIAM-PFM by Paul
Hi,
I've worked with hibernate many years on java projects. But, I am new
using SQLAlchemy. I am very impressed with the capabilities and the
excellent documentation. It really seems very powerful. Our new
project is being written in python -of course. And we are using MySQL
as well.
I've a
discussion_comments)
...but this is still strange with the added enclosing parenthesis.
I'm very sorry to keep belaboring this issue here, but I'm doing a SQL
optimization sweep on my code and this query is tripping me up.
Thanks,
Seth
On Sep 8, 6:01 pm, Michael Bayer mike...@zzzcomputing.com wrote
Michael,
This is not valid SQL being outputted (at least on SQLite MySQL).
There should not be a parenthesis between the first UNION and SELECT.
This causes an SQL error.
Is there a way to reformat the query to get valid SQL?
Thanks,
Seth
On Sep 9, 8:38 am, Michael Bayer mike
, user_id FROM t2
UNION SELECT post_id, user_id FROM t3
I have still not been able to get this query working correctly.
Thanks,
Seth
On Sep 9, 10:34 am, Michael Bayer mike...@zzzcomputing.com wrote:
Seth wrote:
Michael,
This is not valid SQL being outputted (at least on SQLite MySQL
apologize for taking
up so much of your time.
Thanks again,
Seth
On Sep 9, 12:26 pm, Michael Bayer mike...@zzzcomputing.com wrote:
again I apologize for the misunderstanding and I hope this helps with your
issue.
- mike
--~--~-~--~~~---~--~~
You received
.created, P3.updated)
subquery = DBSession.query().from_statement(union_all(q1, q2,
q3)).subquery()
posts = DBSession.query(subquery, User.name).filter
(User.user_id==subquery.c.user_id)
Kind of hackish, but... it seems to work?
Seth
On Aug 28, 12:07 pm, Mike Conley mconl...@gmail.com wrote
However, I can't get SQLAlchemy to replicate the NOT IN (SELECT ...)
subquery setup. It strips the parenthesis after the NOT IN and so I
get a syntax error.
Advice would be appreciated!
Seth
--~--~-~--~~~---~--~~
You received this message because you are subscribed
Thank you Michael,
What about using this type of thing inside another query?
I keep getting:
AttributeError: 'Select' object has no attribute '_nested_statement'
Seth
On Sep 8, 7:16 am, Michael Bayer mike...@zzzcomputing.com wrote:
an example of NOT IN (subquery):
from sqlalchemy
UNION SELECT post_id, user_id
FROM discussions UNION SELECT post_id, user_id
FROM discussion_comments
Thanks again,
Seth
On Sep 8, 2:38 pm, Michael Bayer mike...@zzzcomputing.com wrote:
Seth wrote:
Thank you Michael,
What about using this type of thing inside another query?
I keep
).filter(P2.user_id==User.id)
q3 = DBSession.query(P3.id, P3.user_id, 'P3', P3.title, P3.body,
P3.created, P3.updated, User.name).filter(P3.user_id==User.id)
posts = q1.union_all(q2, q3)
?
Seth
On Aug 27, 2:45 pm, Mike Conley mconl...@gmail.com wrote:
OK, I can mostly answer my own question
q1
Mike,
Very helpful! Seems to work great.
Wanna give me a tip on how to make the user's table join to this query
via the user_id so that I can access the user's information at
something like q.user.email?
Seth
On Aug 26, 9:22 pm, Mike Conley mconl...@gmail.com wrote:
or should be a little
the
ArgumentError?
Thanks,
Seth
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to
sqlalchemy
='posts')
comments = relation('Comments')
How would you apply your suggested mapper() call to this type of
setup? Or do I need to switch things to the more traditional
approach?
Thanks,
Seth
On Aug 25, 9:45 am, Michael Bayer mike...@zzzcomputing.com wrote:
use a recipe almost identical
82 matches
Mail list logo