Re: [sqlalchemy] SQLAlchemy-Continnum over 300 failed tests

2015-09-03 Thread Mike Bayer
On 9/3/15 10:12 AM, Piotr Dobrogost wrote: On Thursday, September 3, 2015 at 3:58:42 PM UTC+2, Michael Bayer wrote: well, I don't even know what SQLAlchemy-Continuum is.Is their bugtracker open on github? You must have forgotten then :) –

Re: [sqlalchemy] Support for Impala?

2015-09-02 Thread Mike Bayer
There appears to be a rudimental dialect delivered with their own DBAPI here: https://github.com/cloudera/impyla/blob/master/impala/sqlalchemy.py So that would be where to go. On 9/2/15 11:40 AM, James Flint wrote: Is this actively being worked on? -- You received this message because

Re: [sqlalchemy] PostgreSQL: problem with simple rowqcount query

2015-09-04 Thread Mike Bayer
On 9/4/15 9:38 AM, Massi wrote: HI everyone, I'm trying to use sqlalchemy (0.9.10) to retrieve the number of rows of table in PostgreSQL, here a stub of the code: I'd highly recommend using psycopg2 as this error is a pg8000-specific quirk. to work around otherwise, you'd need to say

Re: [sqlalchemy] onupdate with ORM

2015-09-04 Thread Mike Bayer
On 9/4/15 10:19 AM, Pavel S wrote: Hi, I have declarative Model with couple of columns, one of them is lastAccess = Column('LastAccess', DateTime, nullable=False, onupdate=datetime.datetime.utcnow) I fetch the object from database like the following: obj =

Re: [sqlalchemy] Question about FAQ entry titled "I’m getting a warning or error about “Implicitly combining column X under attribute Y”"

2015-09-08 Thread Mike Bayer
On 9/8/15 6:00 AM, Piotr Dobrogost wrote: Hi! In the FAQ there's entry titled "I’m getting a warning or error about “Implicitly combining column X under attribute Y”" with the following example: class A(Base): __tablename__ = 'a' id = Column(Integer, primary_key=True) class B(A):

Re: [sqlalchemy] Nested bundles, labels and "Ambiguous column name"

2015-09-08 Thread Mike Bayer
On 9/8/15 4:13 AM, Jacob Magnusson wrote: Michael, Is there any chance we might see support for /with_labels/ in this use case? Even though my "solution" works, it's somewhat of an annoyance with all these warnings being spit out: /SAWarning: Column 'id' on table being replaced by

Re: [sqlalchemy] alembic.op.create_index algorithm=inplace lock=none

2015-09-08 Thread Mike Bayer
On 9/8/15 9:32 AM, murray.was...@lightspeedretail.com wrote: Hi there, Is there any way I can set additional params on alembic.op.create_index. We are using python and MYSQL. Need to add : algorithm=inplace lock=none trying to produce: CREATEINDEX[index_name]ON[table_name]

Re: [sqlalchemy] Tips for schema based db traversal and building

2015-09-08 Thread Mike Bayer
On 9/8/15 12:57 PM, Steve Murphy wrote: A bit difficult is grabbing just certain columns in the select, given that we have only a list of column names. That would be real nice if such a method were available in the core API. For example, a method for select whereby I could supply a simple

Re: [sqlalchemy] contains_eager bug

2015-09-02 Thread Mike Bayer
On 9/2/15 9:57 PM, Dave Vitek wrote: Answering my own question. Here's a patch that seems to fix it, but I am uncertain about whether it breaks other things. Use at your own risk, at least until someone more familiar with this code evaluates it. this is a variant of a known issue, that

Re: [sqlalchemy] Error with SQL Server and utf-8 encoding

2015-09-01 Thread Mike Bayer
On 9/1/15 11:28 AM, Massi wrote: Hi everyone, I'm trying to manage read and write operations of utf-8 unicode strings with SQL Server (sqlalchemy 0.9.10), but I'm having some problems. I correctly write the strings to the database, but when I read them back and try to convert to unicode I

Re: [sqlalchemy] Nested bundles, labels and "Ambiguous column name"

2015-09-08 Thread Mike Bayer
On 9/8/15 12:03 PM, Mike Bayer wrote: On 9/8/15 4:13 AM, Jacob Magnusson wrote: Michael, Is there any chance we might see support for /with_labels/ in this use case? Even though my "solution" works, it's somewhat of an annoyance with all these warnings being spit out:

Re: [sqlalchemy] Re: Support for native PostgreSQL "polygon" type?

2015-09-07 Thread Mike Bayer
On 9/6/15 11:28 AM, Demitri Muna wrote: Hi Ian, Thanks for the reply. On Saturday, September 5, 2015 at 11:53:39 AM UTC-4, Ian McCullough wrote: Is there some compelling reason you wouldn't just install the PostGIS extensions? Assuming there is... There is; I can't use any of

Re: [sqlalchemy] ORM: walk() related objects

2015-09-10 Thread Mike Bayer
On 9/10/15 8:48 AM, Pavel S wrote: Let's say, I have declarative classes A, B, C, D. A is the parent B has FK to A C has FK to B, D has FK to C etc... I'd like to implement _generic method_ walk(obj) which will recursively yield dependent/related objects of obj (which is instance of A).

Re: [sqlalchemy] ORM: walk() related objects

2015-09-10 Thread Mike Bayer
On 9/10/15 9:35 AM, Mike Bayer wrote: On 9/10/15 8:48 AM, Pavel S wrote: Let's say, I have declarative classes A, B, C, D. A is the parent B has FK to A C has FK to B, D has FK to C etc... I'd like to implement _generic method_ walk(obj) which will recursively yield dependent/related

Re: [sqlalchemy] ORM: walk() related objects

2015-09-10 Thread Mike Bayer
On 9/10/15 10:26 AM, Mike Bayer wrote: On 9/10/15 10:13 AM, Ladislav Lenart wrote: Hello. Just a really, really tiny and pedantic correction... The stack variable in the code is in fact a queue. This could potentially surprise some users / readers. To fix, please do one

Re: [sqlalchemy] ORM: walk() related objects

2015-09-10 Thread Mike Bayer
) to pop() here means we are doing depth-first instead of breadth-first. So. Some word that means "collection of things to operate upon"? I've seen "work" used. "buffer" ? eh. HTH, Ladislav Lenart On 10.9.2015 15:48, Mike Bayer wrote: On 9/10/15 9:3

Re: [sqlalchemy] There is any chance to SQLAlchemy works with syncio?

2015-09-16 Thread Mike Bayer
On 9/16/15 10:17 AM, Johnny W. Santos wrote: Hi guys, I would like to know if theres is any chances to SQLAlchemy support asyncio out of the box? Like the ORM and such. Well the "real" answer is "yes", which is that you'd put your ORM business logic in a threadpool using

Re: [sqlalchemy] Re: polymorphic identity after_delete event

2015-09-16 Thread Mike Bayer
On 9/16/15 5:28 AM, Jakub Bąk wrote: Thanks a lot! It works but I still have a problem. I want to make one query to get the root directory, all its children and the filenames of Image objects. My directory model looks like this: | classDirectory(Node): is_root

Re: [sqlalchemy] Mixed data type for a column

2015-09-16 Thread Mike Bayer
On 9/16/15 6:46 AM, Mattias Lagergren wrote: The important part is the casting inside of the case expression: | dynamic_cast=sqlalchemy.sql.expression.case( [ ( variable_register.c.type =='number', sqlalchemy.cast(variable_value.c.value,types.Numeric)

Re: [sqlalchemy] SQLite objects getting closed in wrong thread, if session not explicitly closed

2015-09-11 Thread Mike Bayer
On 9/11/15 1:55 PM, Ben Sizer wrote: I'm using SQLAlchemy 1.0.8 with an SQLite file-based database, running as part of a Flask-based server, and getting some strange results. I'm seeing this exception raised: ProgrammingError: SQLite objects created in a thread can only be used in that

Re: [sqlalchemy] AttributeError: 'NoneType' object has no attribute 'accepts_scalar_loader'

2015-09-15 Thread Mike Bayer
On 9/15/15 2:05 PM, dewey wrote: The contents of the full traceback was: Traceback (most recent call last): File "/opt/paysys/python/lib/python2.7/site-packages/celery/app/trace.py", line 240, in trace_task R = retval = fun(*args, **kwargs) File

Re: [sqlalchemy] Re: polymorphic identity after_delete event

2015-09-15 Thread Mike Bayer
On 9/15/15 10:09 AM, Jakub Bąk wrote: I used before_delete and after_commit and it works like a charm. Thanks again! I have another problem related to this setup. I have a property defined on the Image model: | @property deffilename(self):

Re: [sqlalchemy] Cast model id column from String to Integer

2015-09-15 Thread Mike Bayer
On 9/15/15 1:19 PM, Katie Wurman wrote: Hi, I'm having trouble implementing a model whose 'id' column needs to be cast to Integer type. Below is the implementation I've got so far: class CastToIntegerType(types.TypeDecorator): ''' Converts stored String values to Integer via CAST

Re: [sqlalchemy] AttributeError: 'NoneType' object has no attribute 'accepts_scalar_loader'

2015-09-15 Thread Mike Bayer
On 9/15/15 1:02 PM, dewey wrote: I've got a SA session, and i'm running the following: cot = sess.query(MyTable).get( int(someIntAsString) ) I'm seeing the error: AttributeError: 'NoneType' object has no attribute 'accepts_scalar_loader' I'm guessing that means the record was not

Re: [sqlalchemy] Cast model id column from String to Integer

2015-09-15 Thread Mike Bayer
On 9/15/15 4:10 PM, Mike Bayer wrote: On 9/15/15 2:47 PM, Katie Wurman wrote: class Person(Base): __tablename__ = 'person' id = Column('id_string', CastToIntegerType, primary_key=True) pets = relationship('Pets', primaryjoin='foreign(Pets.person_id)==Person.id') class Pets

Re: [sqlalchemy] Cast model id column from String to Integer

2015-09-15 Thread Mike Bayer
On 9/15/15 2:47 PM, Katie Wurman wrote: Ok thanks! Adding a bind_expression to my CastToInteger type ensures that when Person.id is included in a WHERE clause, the param is cast to varchar. This is ok, except now I have the following situation: class CastToIntegerType(types.TypeDecorator):

Re: [sqlalchemy] Expressions generated by select(...) changes when submitted in session.query

2015-09-15 Thread Mike Bayer
On 9/15/15 4:52 PM, Mourad Ben Cheikh wrote: Hi, I am using sqlalchemy in flask, essentially through flask-sqlalchemy, and my goal is to generate and execute queries on the fly. I am pretty new to sqlalchemy ( a great challenge and a great work) I am using a model generated by automap. The

Re: [sqlalchemy] Cast model id column from String to Integer

2015-09-16 Thread Mike Bayer
OK, new day, new perspectives. This is the best way to do the mapping / type: class CastToIntegerType(TypeDecorator): impl = String def column_expression(self, col): return cast(col, Integer) def process_bind_param(self, value, dialect): return str(value) class

Re: [sqlalchemy] migrating from backref to back_populates -- advice?

2015-09-16 Thread Mike Bayer
maybe you can run through all the mappings with a script and produce a textfile indicating the settings for all the relationships. then you can verify that the back_populates code change produces the same thing. On 9/16/15 3:47 PM, Jonathan Vanasco wrote: I'm about to migrate about 70

Re: [sqlalchemy] most correct way to get the columns in an object?

2015-09-16 Thread Mike Bayer
On 9/16/15 4:30 PM, Jonathan Vanasco wrote: given the object `source`, these both work cols = [c.key for c in list(source.__table__.columns)] cols = [c.name for c in sqlalchemy.orm.class_mapper(source.__class__).mapped_table.c] I'm sure there are other ways. is

Re: [sqlalchemy] AttributeError: 'NoneType' object has no attribute 'accepts_scalar_loader'

2015-09-16 Thread Mike Bayer
check out this case, this is one way to reproduce that: https://bitbucket.org/zzzeek/sqlalchemy/issues/3532/detect-property-being-assigned-to-more On 9/15/15 3:56 PM, dewey wrote: I'll see if I can reproduce this in a simple example.it's currently in a job being run every night from a

Re: [sqlalchemy] possible bug/docs deficiency on classes with multiple identical relationships

2015-09-16 Thread Mike Bayer
On 9/16/15 5:49 PM, Jonathan Vanasco wrote: This drove me crazy for an hour today, until I finally figured out what was going on. I have a class with a few relationships: class Foo(base): # relationships have a prefix that describe the relation l_ (list) or o_ (scalar)

Re: [sqlalchemy] AttributeError: 'NoneType' object has no attribute 'accepts_scalar_loader'

2015-09-17 Thread Mike Bayer
On 9/16/15 8:05 PM, dewey wrote: Hey Mike, I've found and fixed (with help) my problem, but I thought I'd describe it here to support anyone else who hits this... Was not a threading issue..it was a combination of: * data-edge case * bug in our code * bug in how SA was reporting a

Re: [sqlalchemy] Please advice with new oracle 'OFFSET x ROWS FETCH NEXT x ROWS' approach in 12c

2015-09-29 Thread Mike Bayer
On 9/29/15 9:50 AM, Ralph Heinkel wrote: Hi everybody, oracle 12c has received the long awaited possibility to properly provide LIMIT and OFFSET parameters to a select query. See https://oracle-base.com/articles/12c/row-limiting-clause-for-top-n-queries-12cr1 for details. wow! In

Re: [sqlalchemy] Postgres' arrays in subqueries

2015-10-01 Thread Mike Bayer
On 10/1/15 4:35 AM, artee wrote: Mike and others :) I have the following sql: select models.code, *array*( select *(clients.id, clients.code) *from clients group by clients.id, clients.code ) as envs from models I ended with something like this: items =

Re: [sqlalchemy] unregister Tables from Metadata

2015-10-01 Thread Mike Bayer
On 10/1/15 5:56 AM, Pavel S wrote: Hi, we use application-level partitioning (but no real partitioning in mysqld), where new tables are created daily with the same structure, but different name (suffix). * mysqld is shared for these components: * daemon written in C++ o creates

Re: [sqlalchemy] Is there a better and more idiomatic way to accomplish this?

2015-10-01 Thread Mike Bayer
On 10/1/15 11:41 AM, Massimiliano della Rovere wrote: Greetings, I have two questions to the following code that works, but looks dirty to me. Being new to SQLAlchemy I'd like to ask for advices. The database is PostgreSQL. The following check_xyz function must check whether the index

Re: [sqlalchemy] correlate() with aliases having no effect on FROM clause in 1.0.8?

2015-10-02 Thread Mike Bayer
On 9/29/15 8:47 PM, Charles Duffy wrote: From a StackOverflow answer describing use of the correlate() call in SQLALchemy, at http://stackoverflow.com/questions/13056049/how-to-specify-the-from-tables-in-sqlalchemy-subqueries: |>>>printstr(q1)SELECT t3.id AS t3_id FROM tbl AS t3,tbl AS t1

Re: [sqlalchemy] DB sync on application level

2015-09-27 Thread Mike Bayer
On 9/27/15 5:17 PM, Cornelinux K wrote: Hi Michael, thanks for your response. At least it shows me, that obviously this seems to be no common idea - mostly known as a bad idea. I do not want to sync anything on a database level, but on a logical level. It is not important, that entries

Re: [sqlalchemy] ora-25408 can not safely replay call

2015-09-26 Thread Mike Bayer
On 9/26/15 10:28 AM, Abhishek Sharma wrote: Hi Team, We have integrated our Django project with sqlalchemy ORM. Django: 1.4.2 SQLALCHEMY-0.8 Recently we started getting the following error while making the service call and it leads to internal server error: *ora-25408 can not

Re: [sqlalchemy] DB sync on application level

2015-09-26 Thread Mike Bayer
On 9/26/15 6:35 AM, Cornelinux K wrote: Hello, I have an application that uses an SQL database with also many write access. Now I am thinking of high availability. One solution was to set up a mysql master master replication. that's a good solution. But I was thinking, there might be

Re: [sqlalchemy] funky session usage to add join conditions and where clauses

2015-09-26 Thread Mike Bayer
On 9/25/15 12:24 PM, Chris Withers wrote: On 25/09/2015 13:58, Mike Bayer wrote: session.query(A).filter(A.id>10).as_at(now)) you'd need to subclass Query and dig into Query.column_descriptions to get at the existing entities, then add all that criterion. remind me where the d

Re: [sqlalchemy] views

2015-09-26 Thread Mike Bayer
On 9/25/15 9:00 AM, Mike Bayer wrote: On 9/25/15 3:13 AM, Chris Withers wrote: Hi All, Is this still the best way to hand views, or are there later and greater things in 1.0+? https://bitbucket.org/zzzeek/sqlalchemy/wiki/UsageRecipes/Views How would I make a view behave like a normal

Re: [sqlalchemy] get_schema_names doesn't work with SQLite attached databases

2015-09-09 Thread Mike Bayer
On 9/9/15 4:59 PM, Van Klaveren, Brian N. wrote: Hi, I'm trying to find the attached databases of a SQLite database. I was expecting Inspector.get_schema_names to return something like: $ sqlite3 foo.db sqlite> create table a (a_id integer); sqlite3 bar.db sqlite> create table b (b_id

Re: [sqlalchemy] Capturing query parameters

2015-09-18 Thread Mike Bayer
On 9/18/15 3:22 PM, George Reilly wrote: I find [SQLTap](http://sqltap.inconshreveable.com/) invaluable for profiling SQLAlchemy queries. Currently, I've reduced one operation in our system from nearly 12,000 queries to 800, and I'm not finished yet. SQLTap listens for the before_execute

Re: [sqlalchemy] loading of relationships

2015-09-24 Thread Mike Bayer
On 9/24/15 9:32 AM, Julien Cigar wrote: Hello, I'm using SQLAlchemy 1.0.8 with joinedload inheritance. On one of the Child I have a relationship property and I wondered if there is an easy way to innerjoin=True this relation only in a non-polymorphic context ? In my case I have the base

Re: [sqlalchemy] has anyone used/abused events to reflect db changes on cached orm objects?

2015-09-22 Thread Mike Bayer
On 9/22/15 1:52 PM, Jonathan Vanasco wrote: This is, admittedly, an abuse of SqlAlchemy. I'm wondering if anyone else has dealt with this situation before and how they handled it. We have a handful of situations where SqlAlchemy generates a raw sql update against a table. Something like

Re: [sqlalchemy] "No such event 'instrument_class' for target" for mixin that needs to listen to 'instrument_class'

2015-09-24 Thread Mike Bayer
On 9/24/15 2:06 PM, Chris Withers wrote: Hi All, I have a mixin class here that I've factored out of one project as I want to use it in another one: https://github.com/Mortar/mortar_mixins/blob/master/mortar_mixins/temporal.py The problem is that importing the module seems to result in

Re: [sqlalchemy] views

2015-09-25 Thread Mike Bayer
On 9/25/15 5:26 AM, Chris Withers wrote: Also forgot to ask... What's support like in Alembic for creating views (especially if the views are described by a declarative class as I'm looking for below...) the trick with views is migrating them when the tables change without lots of

Re: [sqlalchemy] Encapsulate multiple columns into one

2015-09-22 Thread Mike Bayer
On 9/22/15 7:18 AM, Yegor Roganov wrote: I know that I can encapsulate multiple columns into one using either composite column or hybrid_property, but unfortunatelly neither suits me 100%. Let's say I have a `File` model which includes fields `id`, 'file_name`, `storage_type`, and there is

Re: [sqlalchemy] Capturing query parameters

2015-09-19 Thread Mike Bayer
On 9/18/15 7:58 PM, George Reilly wrote: Thanks for the prompt answer. I tried after_cursor_execute, but it didn't really help as I just got a tuple of the values, without a clear way to associate them with the parameter names. Ultimately, I found that the following gives me the best

Re: [sqlalchemy] create and update table dynamically in declarative base

2015-09-19 Thread Mike Bayer
On 9/17/15 5:11 PM, Nana Okyere wrote: So I have a form that will collect the name attribute of TableInfo. Now, how do I dynamically - in runtime- create an empty table with the name attribute given? I'm not sure what this is asking. An "empty" table is this: t = Table('mytable',

Re: [sqlalchemy] how to find none-referenced objects

2015-09-21 Thread Mike Bayer
On 9/20/15 8:05 AM, c.bu...@posteo.jp wrote: Instances of 'A' can have many references to instances of 'B'. I want to find all 'B' instances that are not referenced by an 'A'. I am not sure if this is possible with SQLAlchemy-Query. And I am not sure if the backref() part in the code is

Re: [sqlalchemy] Dynamic Declarative Class Generation and "TypeError: Boolean value of this clause is not defined" when doing help()

2015-09-21 Thread Mike Bayer
On 9/21/15 4:08 PM, Cliff Hill wrote: So, I have some code that is constructing a declarative table definition on the fly, built from a YAML file. It works great. However, when I try to do *help(tablename)*, I get the following error: Python 3.4.3 (default, May 14 2015, 09:48:44)

Re: [sqlalchemy] how to dynamically work with an aliased table?

2015-09-25 Thread Mike Bayer
On 9/25/15 2:41 AM, David Allouche wrote: On 24 Sep 2015, at 17:38, Jonathan Vanasco > wrote: On Thursday, September 24, 2015 at 3:05:56 AM UTC-4, David Allouche wrote: That looks like the right approach. There is probably

Re: [sqlalchemy] Storing data on an instance that's deleted when the object is expired

2015-09-25 Thread Mike Bayer
On 9/25/15 8:22 AM, Adrian wrote: For some methods/properties on a model it might be useful to memoize its result. There are some common decoratos such as cached_property from werkzeug which simply add the value to the object's __dict__ after retrieving it the first time (thus not calling

Re: [sqlalchemy] views

2015-09-25 Thread Mike Bayer
On 9/25/15 3:13 AM, Chris Withers wrote: Hi All, Is this still the best way to hand views, or are there later and greater things in 1.0+? https://bitbucket.org/zzzeek/sqlalchemy/wiki/UsageRecipes/Views How would I make a view behave like a normal declarative class (column attributes,

Re: [sqlalchemy] lowercase identifiers in Oracle

2015-10-05 Thread Mike Bayer
On 10/5/15 5:21 AM, Massimiliano della Rovere wrote: The quoted_name tracebacks (i.e. is not enough) with at FOREIGN KEYS, probably with other constructs too. # this works fine Table( quoted_name("x", quote=True), metadata, schema=schemaname, autoload=True,

Re: [sqlalchemy] lowercase identifiers in Oracle

2015-10-05 Thread Mike Bayer
On 10/5/15 9:28 AM, Massimiliano della Rovere wrote: I've found a solution to the reflect problem, but, given my limited knowledge of SQLAlchemy, I do not know how it performs and whether there is better one. that was the workaround I was going to suggest, so stick with that until 1.0.9

Re: [sqlalchemy] session.is_modified() returns false positives sometimes

2015-12-08 Thread Mike Bayer
On 12/08/2015 07:41 AM, Юрий Пайков wrote: > I run a program which creates, fills and merges to DB a list of mapped > objects. I need to know if a merge created a new instance in a database > or if it updated previously existing one or if it did noop. When I know > the instance is persistent, my

Re: [sqlalchemy] post_update issue

2015-12-02 Thread Mike Bayer
On 12/01/2015 07:24 PM, Thorsten von Stein wrote: > The following issue, which puzzled for several days, exists in several > versions. I verified that it applies to version 1.0.9 > > In my understanding, the post_update flag is required on a relationship > between to classes A and B if there is

Re: [sqlalchemy] How to get id from newly inserted row

2015-11-29 Thread Mike Bayer
On 11/29/2015 10:50 AM, Sami Pietilä wrote: > Hi, > > I have postgresql database with "records" table. There is "id" > (bigserial unique primary key) column. I need to insert a row in such a > way that I get id from newly inserted row. > > ins = records.insert() > results = conn.execute(ins) >

Re: [sqlalchemy] Re: postgresql, jsob and like operator

2015-12-01 Thread Mike Bayer
On 12/01/2015 12:49 PM, Jonathan Vanasco wrote: > I don't think you can get that exact query staying within the ORM's > cross-platform functionality -- I don't think there is anything that can > generate the `::` version of casting... but I think something like this > should produce the same

Re: [sqlalchemy] non-table DDL elements and MetaData objects

2015-12-01 Thread Mike Bayer
On 12/01/2015 02:49 PM, Chris Withers wrote: > On Tue, Dec 1, 2015 at 8:17 AM, Chris Withers > <ch...@simplistix.co.uk> wrote: >> >> I'm also looking for two events to listen to: >> >> - once at 'database creation' time, so set up some stored >>

Re: [sqlalchemy] Splitting a table ?

2015-12-02 Thread Mike Bayer
On 12/02/2015 10:18 AM, Jonathan Vanasco wrote: > > I recently had to "split" or partition another table into 2 -- one of high > write and low write access. The new table is just the high-write columns > fkey'd onto the original table, and handled with a relationship. > > I was wondering if

Re: [sqlalchemy] why does attribute_mapping_collection not throw a valueerror on key mismatch?

2015-12-09 Thread Mike Bayer
On 12/09/2015 12:04 PM, Pau Tallada wrote: > Hi, > > Following on the documentation > (http://docs.sqlalchemy.org/en/latest/orm/collections.html?highlight=collection_class#dictionary-collections) > > I seem to understand that attribute_mapped_should verify that the key > used is the same as

Re: [sqlalchemy] why does attribute_mapping_collection not throw a valueerror on key mismatch?

2015-12-09 Thread Mike Bayer
On 12/09/2015 12:16 PM, Mike Bayer wrote: > > > On 12/09/2015 12:04 PM, Pau Tallada wrote: >> Hi, >> >> Following on the documentation >> (http://docs.sqlalchemy.org/en/latest/orm/collections.html?highlight=collection_class#dictionary-collec

Re: [sqlalchemy] session.is_modified() returns false positives sometimes

2015-12-09 Thread Mike Bayer
On 12/09/2015 02:07 AM, Юрий Пайков wrote: > > Ok, here is the test > code https://gist.github.com/ojomio/941d03b728a88d93d010 > Apart from reproducing the (seeming) problem, it prints out > "PASSIVE_NO_RESULT"(yes, you were right about the name) which is /in/ > committed_state great, thanks.

Re: [sqlalchemy] Explicitly name the not null constraint for an Oracle primary key

2015-12-04 Thread Mike Bayer
On 12/04/2015 07:25 AM, Thijs Engels wrote: > Dear all, > > For maintenance purposes I have aiming to ensure that ALL database > constraint have an explicit name (as recommended here as well: > http://alembic.readthedocs.org/en/latest/naming.html) > > With the NOT NULL constraints this can be

Re: [sqlalchemy] Using bindparams in a lazily loaded relationship

2015-12-04 Thread Mike Bayer
On 12/04/2015 10:18 AM, Daniel Thul wrote: > I configured a relationship to use a bindparam as part of its > primaryjoin condition. > This works as long as the relationship is loaded eagerly. As soon as I > switch to lazy loading it won't resolve the relationship properly. > I guess this is

Re: [sqlalchemy] Re: inserts rows in wrong order

2015-12-04 Thread Mike Bayer
On 12/04/2015 01:55 PM, Nana Okyere wrote: > Much thanks. > I think you may have hinted on something about the order in which the > database returns rows. I thought that it always returns the rows in the > order they were inserted. From what you're saying, that's a wrong > assumption. So to

Re: [sqlalchemy] Bulk insert using bulk_insert_mappings

2015-12-03 Thread Mike Bayer
On 12/03/2015 11:28 AM, Horcle wrote: > I am trying to do a bulk insert of a large list of dictionaries of the form: > > results = [{'attribute': u'SEX', 'value_d': 0.0, 'value_s': u'M', > 'sid': 1L}, >{'attribute': u'SEX', 'value_d': 0.0, 'value_s': u'M', > 'sid': 2L}, >

Re: [sqlalchemy] Insert new column in an existing database

2015-12-03 Thread Mike Bayer
hello - you need to use the SQLAlchemy API fully, the code example below is using the SQLite DBAPI directly. Go through the tutorial at http://docs.sqlalchemy.org/en/rel_1_0/core/tutorial.html to see how to properly invoke SQL with SQLAlchemy. On 12/03/2015 12:19 AM, Jothybasu Selvaraj

Re: [sqlalchemy] load_only doesn't affect joins

2015-12-03 Thread Mike Bayer
On 12/03/2015 10:08 AM, Mike Bayer wrote: > > > On 12/03/2015 06:16 AM, Ofir Herzas wrote: >> load_only as stated >> in http://docs.sqlalchemy.org/en/latest/orm/loading_columns.html does >> the following: >> "An arbitrary set of columns can be sel

Re: [sqlalchemy] load_only doesn't affect joins

2015-12-03 Thread Mike Bayer
On 12/03/2015 06:16 AM, Ofir Herzas wrote: > load_only as stated > in http://docs.sqlalchemy.org/en/latest/orm/loading_columns.html does > the following: > "An arbitrary set of columns can be selected as “load only” columns, > which will be loaded *while deferring all other columns* on a given >

Re: [sqlalchemy] firebird3 support

2015-12-03 Thread Mike Bayer
Hi Treeve - these look pretty good, is there any chance you can submit as a single patch to https://github.com/zzzeek/sqlalchemy/pulls, and additionally what are the results when you've run the tests? - mike On 12/03/2015 04:27 AM, Treeve Jelbert wrote: > I have been using sqlalchemy with

Re: [sqlalchemy] non-table DDL elements and MetaData objects

2015-12-02 Thread Mike Bayer
On 12/02/2015 02:13 AM, Chris Withers wrote: > On 02/12/2015 00:08, Mike Bayer wrote: >> On 12/01/2015 02:49 PM, Chris Withers wrote: >>> - once at 'database creation' time, so set up some stored >>> procedures. (I know SQLAlchemy doesn't create databases it

Re: [sqlalchemy] session.is_modified() returns false positives sometimes

2015-12-09 Thread Mike Bayer
On 12/09/2015 01:18 PM, Юрий Пайков wrote: > Thank you for the detailed explanation of what happens. Now I > understand. Shame on me I hadn't noticed this in the docs... > Everything which deals with expiration and object state business is > always a bit over my head... > > You said it mostly

Re: [sqlalchemy] insert.from_select and include_defaults=True causing bindparam name conflict

2015-12-09 Thread Mike Bayer
On 12/09/2015 12:48 PM, Jonathan Beluch wrote: > Hi, using sqlalchemy 1.0.9 and python 2.7.10. > > | > import sqlalchemy as sa > > meta = sa.MetaData() > table = sa.Table('mytable', meta, > sa.Column('foo', sa.String), > sa.Column('bar', sa.String, default='baz'), > ) > > select =

Re: [sqlalchemy] copy tables with circular dependency

2015-12-10 Thread Mike Bayer
On 12/10/2015 08:02 AM, Leily Zafari wrote: > Hello, > I want to copy some tables from one database to another using > SQLAlchemy. The tables have circular dependency which is resolved by > use_alter attribute. > > > class Product(Base): > __tablename__ = 'products' >

Re: [sqlalchemy] table_per_relation ORM example and declarative objects

2015-12-10 Thread Mike Bayer
On 12/10/2015 10:21 AM, Michal Petrucha wrote: > Hello alchemists, > > There's something that's been bugging me for a while now. I even > asked about it on [stackoverflow][1], but it didn't get much > attention there. It's been suggested to me on IRC that this > mailing list might be a better

Re: [sqlalchemy] postgres "similar to" in sqlalchemy expressions

2015-12-11 Thread Mike Bayer
yes, if you were feeling enthusiastic you could make your own operators: http://docs.sqlalchemy.org/en/rel_1_0/core/custom_types.html#redefining-and-creating-new-operators On 12/11/2015 07:53 AM, Chris Withers wrote: > Hi All, > > Just wanted to double check, is this still the best way to do

Re: [sqlalchemy] how to use postgresql json type in sql expression language

2015-12-11 Thread Mike Bayer
All SQL operators are agnostic of the ORM, docs for the JSON type and examples of its special operators are at: http://docs.sqlalchemy.org/en/rel_1_0/dialects/postgresql.html?highlight=json#sqlalchemy.dialects.postgresql.JSON On 12/11/2015 03:34 AM, kk wrote: > Dear all, > I am using

Re: [sqlalchemy] How to commit objects with circular FK references?

2015-12-11 Thread Mike Bayer
On 12/11/2015 05:25 PM, Gerald Thibault wrote: > I am basing my question off the code > at > http://docs.sqlalchemy.org/en/latest/orm/relationship_persistence.html#rows-that-point-to-themselves-mutually-dependent-rows, > with a few changes. > > I am trying to handle a situation very similar to

[sqlalchemy] SQLAlchemy 1.0.10 Released

2015-12-11 Thread Mike Bayer
SQLAlchemy release 1.0.10 is now available. Release 1.0.10 continues with maintenance fixes as we continue major development on the 1.1 series. Fixes here include a handful of fairly obscure ORM issues, as our userbase continues to use the new loader option system introduced in 0.9 more deeply,

Re: [sqlalchemy] Isolating event listeners on Engine

2015-12-16 Thread Mike Bayer
On 12/16/2015 04:07 PM, Kai Groner wrote: > Hi, > > I work on a project that uses dependency injection. We want to log > queries in the context of a particular instantiation of the injector. > This means that when we register an event listener, that listener has > references to a unique

Re: [sqlalchemy] table_per_relation ORM example and declarative objects

2015-12-14 Thread Mike Bayer
On 12/14/2015 03:08 AM, Michal Petrucha wrote: > On Thu, Dec 10, 2015 at 12:31:33PM -0500, Mike Bayer wrote: >> >> >> On 12/10/2015 10:21 AM, Michal Petrucha wrote: >>> Hello alchemists, >>> >>> There's something that's been bu

Re: [sqlalchemy] Using Hybrids for encryption with varying keys

2015-12-14 Thread Mike Bayer
On 12/14/2015 07:35 AM, ThereMichael wrote: > I would say "from a Python function" which could receive some context. > > Here's why: The keys are stored in an external keystore, which is keyed > off of a value in the row. Notionally, the table would look > like this: > > create table secure

Re: [sqlalchemy] Query-invoked autoflush error obfuscated by state_dict KeyError

2015-12-14 Thread Mike Bayer
On 12/14/2015 10:47 AM, Drachenfels wrote: > I have following method in my framework: > > @models.managed_commit > def create_article(self, user_uid, title, **kwargs): > user = user_manager.UserManager().get_user_by_uid(user_uid) > > # create empty article >

Re: [sqlalchemy] Using Hybrids for encryption with varying keys

2015-12-13 Thread Mike Bayer
On 12/13/2015 08:29 PM, Michael Wilson wrote: > Hi, > > I read with great interest these examples: > > https://bitbucket.org/zzzeek/sqlalchemy/wiki/UsageRecipes/SymmetricEncryption > > Which use hybrid_property or TypeDecorators to implement encryption. > > My question is, now would you use

Re: [sqlalchemy] How to commit objects with circular FK references?

2015-12-13 Thread Mike Bayer
On 12/12/2015 09:56 PM, Gerald Thibault wrote: > I am loading data from json files, and then creating instances via > ObjClass(**data), loading them into a session, and committing. I do not > see an easy way to go from having an integer foreign_key value to > populating the relationship with the

Re: [sqlalchemy] How to commit objects with circular FK references?

2015-12-11 Thread Mike Bayer
On 12/11/2015 07:47 PM, Gerald Thibault wrote: > Is there a way to perform a Metadata.create_all() but have it only > create the tables, without any of the FKs? And then create the FKs in > one go after the fixture data has been loaded into the DB? first off, this is unnecessary because the DDL

Re: [sqlalchemy] naming convention

2015-12-12 Thread Mike Bayer
On 12/12/2015 04:42 AM, Ofir Herzas wrote: > I want to start using the naming convention but have several questions > regarding this feature: > > 1. Does the naming convention support Sequences? If not, what's the > proper way of handling them? the Sequence object is a free-standing

Re: [sqlalchemy] How to commit objects with circular FK references?

2015-12-12 Thread Mike Bayer
On 12/12/2015 06:31 PM, Gerald Thibault wrote: > I ended up with the following code to preprocess the session and collect > the problematic updates into a collection, which I then issue after the > initial flush. It looks really ugly, and I'm wondering if any of this > could be more easily

[sqlalchemy] Alembic 0.8.4 Released

2015-12-15 Thread Mike Bayer
Alembic 0.8.4 is now available. Changes in this release include fixes to batch mode and autogeneration. Full changelog is at: http://alembic.readthedocs.org/en/latest/changelog.html#change-0.8.4 Download Alembic 0.8.4 at: https://pypi.python.org/pypi/alembic -- You received this message

Re: [sqlalchemy] Association Proxy

2015-12-16 Thread Mike Bayer
On 12/16/2015 05:40 AM, Jitesh Nair wrote: > I am trying to convert my association table to a class view and using > associationproxy to link them. When i try to append them, it fails. > *My code:* > | > > classHospitalList(db.Model): > id=db.Column(db.Integer,primary_key=True) >

Re: [sqlalchemy] Difference between insert().values() and connection.execute(insert, values) using psycopg2

2015-12-16 Thread Mike Bayer
On 12/16/2015 08:33 AM, viktor.fors...@gmail.com wrote: > Hi, > > Today we increased the performance of one of our services eightfold by > changing the row: > > connection.execute(insert_statement, values=[...]) > > into > > insert_statement = table.insert().values(values) >

Re: [sqlalchemy] Re: control over metadata reflect

2015-12-10 Thread Mike Bayer
On 12/10/2015 08:06 AM, mdob wrote: > I think I got it. > > | > ||metadata =MetaData() > ||insp =reflection.Inspector.from_engine(engine) > fortable_name ininsp.get_table_names(self.db_schema): > columns =[col['name']forcol >

Re: [sqlalchemy] Determination of string lengths

2015-12-10 Thread Mike Bayer
On 12/10/2015 12:08 PM, Jonathan Vanasco wrote: > `sqlalchemy.func` does not map anything. It is a namespace for a > factory generator. anything you access with it becomes a function of > that caller's name. > > for example: > > filter( func.foo(table.column) > 1 ) > > produces > >

Re: [sqlalchemy] How do a I create Postgres Materialized View using SQLAlchemy?

2015-12-14 Thread Mike Bayer
On 12/14/2015 05:33 PM, Jeff Widman wrote: > > the descriptions on that page for several other methods say 'see > > execute_at() for more information' so it doesn't exactly "feel" > deprecated. > > I see it just at DDLElement.execute() where that doc should be updated. > Where

<    1   2   3   4   5   6   7   8   9   10   >