Re: [sqlalchemy] SAWarnings when using history_meta.py versioning and Inheritance.

2014-10-17 Thread Mike Bayer
On 10/17/2014 02:52 PM, JPLaverdure wrote: > Hello, > > It seems a number of SAWarnings are being thrown whenever I > instantiate Versioned objects which make use of inheritance: > > | > SAWarning:Implicitlycombining column container_history.changed > withcolumn barcoded_container_history.changed

Re: [sqlalchemy] Long transactions with SQLite (and of course locks)

2015-03-31 Thread Mike Bayer
On 3/31/15 7:23 PM, Eric Smith wrote: > Environment: SQLAlchemy 0.9.7, SQLite back-end, autoflush=True, mostly > using scoped session, multi-platform Python 2.7 > > I'm working on a multi-threaded app, but with fairly low concurrency > (user actions and scheduled tasks are on different threads, f

Re: [sqlalchemy] Inherited class column override

2015-04-01 Thread Mike Bayer
On 4/1/15 4:55 AM, Pierre B wrote: > Unfortunately I'm inheriting the relational model from an old > application. I have dozens of tables using a single junction table for > associations. > I can not completely redesign my relational model because it needs to > be compatible with the old applicat

Re: [sqlalchemy] Long transactions with SQLite (and of course locks)

2015-04-01 Thread Mike Bayer
On 4/1/15 12:08 PM, Eric Smith wrote: > Thanks Michael -- I appreciate how responsive you are to questions. > > Yes, it would have been more precise to talk about pysqlite's locking > model rather than SQLite's. I'm hesitant to increase the lock timeout > because I don't think I want any transact

Re: [sqlalchemy] Inherited class column override

2015-04-01 Thread Mike Bayer
On 4/1/15 10:28 AM, Pierre B wrote: > Here's a simple visual of the schema OK, so that's called a polymorphic foreign key. SQLAlchemy doesn't have first class support for this concept because it's relationally incorrect, but there is an example at http://docs.sqlalchemy.org/en/rel_0_9/_modules/

Re: [sqlalchemy] Query.delete() ignores outerjoin

2015-04-01 Thread Mike Bayer
On 4/1/15 1:21 PM, Simon Beertree wrote: > Hi all, > > I have two classes, Product and Price, that have a many-to-many > relation through a secondary table (see attached test file). I'm > trying to delete all Prices that are not related to any Product. I > would expect the last query in the file

Re: [sqlalchemy] Re: regression? in SA 1.0.0b3?

2015-04-01 Thread Mike Bayer
On 4/1/15 4:47 PM, Jonathon Nelson wrote: > I spoke too soon. Adding the .close() did not change things. well adding tests for these is hard since I can't really get the right sequence of events to occur here, but the fix is just to put a list() around the call which I've done, so try out master

Re: [sqlalchemy] PostgreSQL UNION with ORDER or LIMIT parenthesis patch

2015-04-02 Thread Mike Bayer
haha it's not resolved :) UNIONs are really tough, as are SQLite's choice of quirks in this area. On 4/1/15 11:27 PM, Charles Leifer wrote: > Funnily enough I ran into this particular question regarding Peewee > ORM and, googling "Postgresql UNION parentheses", I found this post. I > ran into th

Re: [sqlalchemy] Nested transaction rollback does not undo changes to instances

2015-04-02 Thread Mike Bayer
On 4/2/15 10:01 AM, Chris Wilson wrote: > Dear SQLAlchemy developers, > > I think I've found a problem with SQLAlchemy not rolling back changes > to instances that are committed in an inner nested transaction, when > the outer nested transaction rolls back. > > The manual says: > > When begin

Re: [sqlalchemy] Nested transaction rollback does not undo changes to instances

2015-04-02 Thread Mike Bayer
On 4/2/15 11:54 AM, Mike Bayer wrote: > > it's a bug, and I've captured the origin, diagnosis and probable > solution here: > https://bitbucket.org/zzzeek/sqlalchemy/issue/3352/nested-begin_nested-blocks-dont-track this issue is fixed for 0.9.10 and 1.0.0b5, you can test n

Re: [sqlalchemy] 0.9.7: Intermittently find a dead weakref to a listens_for function while checking _stored_in_collection of a registry

2015-04-02 Thread Mike Bayer
On 4/2/15 4:28 PM, Evan James wrote: > Hi folks, > > While running my test suite, I hit an issue with the following stack > trace: > > | > ERROR at setup of test_track_before_delete > > > request > =>,engine > =Engine(sqlite:///test.db) > > > > > @pytest.fixture > > defdatabase_sessio

[sqlalchemy] SQLAlchemy 1.0.0b5 Released

2015-04-03 Thread Mike Bayer
SQLAlchemy release 1.0.0b5 is now available. This release is yet another set of fixes for issues reported by beta testers. At this point, 1.0.0 is ready to go and should be released very soon. In preparation for 1.0.0, production installations that haven't yet been tested in the 1.0 series shoul

Re: [sqlalchemy] generating safe sqlalchemy.sql.text elements?

2015-04-03 Thread Mike Bayer
On 4/3/15 3:10 PM, Jonathan Vanasco wrote: > I have an include file that generates a handful of timestamp clauses: > > def sql_now(): > return sqlalchemy.sql.text("(CURRENT_TIMESTAMP AT TIME ZONE 'UTC')") > > def sql_now_minus_10_minutes(): > return sqlalchemy.sql.text("(CURRENT_TIMESTAMP AT TIME

Re: [sqlalchemy] Redshift - approximate count

2015-04-03 Thread Mike Bayer
I think you can get this with select.prefix_with(): http://docs.sqlalchemy.org/en/rel_0_9/core/selectable.html?highlight=prefix#sqlalchemy.sql.expression.Select.prefix_with On 4/3/15 8:22 PM, Kristi Tsukida wrote: > Redshift supports a modifier "approximate" as in > > SELECT APPROXIMATE COUNT(*

Re: [sqlalchemy] create_engine() creates sqlite database - how to disable / prevent this?

2015-04-04 Thread Mike Bayer
On 4/4/15 4:38 AM, Duke Dougal wrote: > Is there a way to have create_engine NOT create a sqlite database in > the event that one does not exist? I think you need to reword this question. Right now it says, "Is there a way to call a function X() and have it NOT do X?" Doesn't make much sense.

Re: [sqlalchemy] error in query many to many

2015-04-04 Thread Mike Bayer
On 4/4/15 11:27 AM, biohege...@gmail.com wrote: > Hi, > > I get a strange error when querying a many-to-many relationship > (Protein - Omim / protein - omim). > sqlalchemy 0.9.9 > > o=Omim.query.filter(Omim.acc=="157140").one() # this is OK > o.proteins # this gives an error > > 2015-04-04 17:16:

Re: [sqlalchemy] SQLAlchemy delay reconnecting

2015-04-04 Thread Mike Bayer
On 4/4/15 11:42 AM, Henrique Fleury wrote: > When the database restarts my services are flooding the database > connection. I wonder if in SQLAlchemy has a parameter that step > create_engine () it does a delay between an attempt and another > connection. I need him to try to connect if you can n

Re: [sqlalchemy] error in query many to many

2015-04-04 Thread Mike Bayer
On 4/4/15 12:14 PM, Mike Bayer wrote: > > > On 4/4/15 11:27 AM, biohege...@gmail.com wrote: >> Hi, >> >> I get a strange error when querying a many-to-many relationship >> (Protein - Omim / protein - omim). >> sqlalchemy 0.9.9 >> >> o=Omim.

Re: [sqlalchemy] create_engine() creates sqlite database - how to disable / prevent this?

2015-04-04 Thread Mike Bayer
On 4/4/15 4:10 PM, Duke Dougal wrote: > OK I'll try again, apologies for not being clear. > > I want to connect to a Sqlite database if it exists, but if it does > not exist, I want to execute my custom database creation code., which > looks like this: then use Python to check for the file: impo

Re: [sqlalchemy] How to query postgresql JSONB columns?

2015-04-04 Thread Mike Bayer
On 4/4/15 7:22 PM, Daniel Kerkow wrote: > Hi, > I am new to SQLAlchemy, doing my first steps with Flask. > I have the following model using JSONB data type in PostgreSQL. > > The JSON data looks like > > | > {'key1':'value1','key2':'value2'} > | > > The Docs are relatively sparse regarding this t

Re: [sqlalchemy] How to query postgresql JSONB columns?

2015-04-04 Thread Mike Bayer
On 4/4/15 7:29 PM, Mike Bayer wrote: > > > On 4/4/15 7:22 PM, Daniel Kerkow wrote: >> Hi, >> I am new to SQLAlchemy, doing my first steps with Flask. >> I have the following model using JSONB data type in PostgreSQL. >> >> The JSON data looks like >

Re: [sqlalchemy] How to query postgresql JSONB columns?

2015-04-04 Thread Mike Bayer
On 4/4/15 7:47 PM, Daniel Kerkow wrote: > > 2015-04-05 1:29 GMT+02:00 Mike Bayer <mailto:mike...@zzzcomputing.com>>: > > > > On 4/4/15 7:22 PM, Daniel Kerkow wrote: >> Hi, >> I am new to SQLAlchemy, doing my first steps with Flask. >>

Re: [sqlalchemy] Deleting object attributes to avoid merge comparison no longer works in 1.0

2015-04-04 Thread Mike Bayer
On 4/5/15 12:32 AM, Russ wrote: > I have some buried-in-the-codebase-since-0.7 upsert code that uses > `merge`. In order to avoid certain attributes from being used in the > merge comparison, the attributes were deleted using delattr.. > > The code looks something like this: > > db_obj = sess.qu

Re: [sqlalchemy] Re: error in query many to many

2015-04-04 Thread Mike Bayer
On 4/5/15 12:54 AM, biohege...@gmail.com wrote: > Thanks for your input! It helped my to find a bug in my code. > I inserted 0 for false, 1 and 2 for true. > > However, inserting a "bad" value for boolean using SQLAlchemy should > also result in an exception and not only selecting a boolean with

Re: [sqlalchemy] Eager loading of filtered children

2015-04-05 Thread Mike Bayer
On 4/5/15 8:46 AM, Yegor Roganov wrote: > Given the User-Addresses schema as in the docs, I need to select all > users along with only those email addresses which end with "@gmail.com". > The question is how do I group these filtered emails by user? > Apparently I can use `contains_eager` to writ

Re: [sqlalchemy] Python 3 and mysql

2015-04-05 Thread Mike Bayer
On 4/5/15 1:49 PM, Thomas Tanner wrote: > Hello, > > which Python 3 compatible MySQL driver is recommended for SA? > I couldn't find a single package which both installs cleanly with pip > and passes the SA test suite. I've tried mysqlclient, mysqlconnector, > cymysql, oursql on OSX. Right now t

Re: [sqlalchemy] SQLite Multithreading issue

2015-04-06 Thread Mike Bayer
On 4/6/15 7:12 PM, arash afshar wrote: I am using sqlalchemy version 0.9.9 with SQLite backend which stores data on a file on disk. Moreover, I am using ORM model for all my queries and handle sessions using scoped_session to work with multiple threads. The application is a desktop application

Re: [sqlalchemy] Test test/engine/test_pool.py::QueuePoolTest::()::test_queuepool_close fails

2015-04-07 Thread Mike Bayer
it's a test that very seldom fails in some cases no matter what, as it's checking reference counts on objects that are expected to be garbage collected without any cycles. A failure of this test is not strictly a "bug", it just refers to connections or cursors that are not collected immediatel

Re: [sqlalchemy] Reverse delete orphan?

2015-04-07 Thread Mike Bayer
On 4/7/15 4:43 PM, Jonathan Gordon wrote: How can I cascade delete from a many to one only when deleting the many means this one has no other children? Imagine the following mapping: class Container(Base): __tablename__ = 'container' pk = sa.Column(sa.Integer, primary_key=True) entries

Re: [sqlalchemy] Test test/engine/test_pool.py::QueuePoolTest::()::test_queuepool_close fails

2015-04-07 Thread Mike Bayer
On 4/7/15 4:33 PM, Mike Bayer wrote: it's a test that very seldom fails in some cases no matter what, as it's checking reference counts on objects that are expected to be garbage collected without any cycles. A failure of this test is not strictly a "bug", it just refe

Re: [sqlalchemy] Test test/engine/test_pool.py::QueuePoolTest::()::test_queuepool_close fails

2015-04-07 Thread Mike Bayer
On 4/7/15 4:33 PM, Mike Bayer wrote: it's a test that very seldom fails in some cases no matter what, as it's checking reference counts on objects that are expected to be garbage collected without any cycles. A failure of this test is not strictly a "bug", it just refe

Re: [sqlalchemy] Any recommended approach for creating a new dialect?

2015-04-07 Thread Mike Bayer
On 4/7/15 1:59 PM, Ralph Heinkel wrote: Hello dialect experts, what would be the best approach for creating a SqlAlchemy dialect for a new database system? Are there any recipes available for this area, or is the way to go to read code of existing dialects and derive my own dialect from thos

Re: [sqlalchemy] Specifying "itersize" when "streaming_results=True" for psycopg2 driver ?

2015-04-08 Thread Mike Bayer
On 4/8/15 6:43 AM, Dorian Hoxha wrote: I searched documentation, mailing list, issue-list, code (on github), google, and couldn't find for a way to set the "iterszie", the number of rows to get on each batch when streaming results with psycogp2. we don't have public API for that attribute at

Re: [sqlalchemy] Eagerly loading backrefs

2015-04-08 Thread Mike Bayer
On 4/8/15 3:22 AM, Sebastian Eckweiler wrote: Hi there - I'm having trouble working with backrefs of detached objects. I'm basically working with a extended version of the code below: | classConfig(Base): __tablename__ ='config' ID =Column('ID',Integer,primary_key=True) name =Col

Re: [sqlalchemy] Unable to make referential integrity work

2015-04-10 Thread Mike Bayer
On 4/10/15 4:10 PM, Shola Smith wrote: I am unable to make reference between two tables work using flask-sqlalchemy. Please find attached the file. I get an error "expected string or buffer". Please, could someone tell me what I am doing wrong? And the best way to go about it. Thanks the scr

Re: [sqlalchemy] Constraint naming conventions and MySQL's 64 character name limit

2015-04-10 Thread Mike Bayer
On 4/10/15 4:55 PM, Giovanni Torres wrote: CREATE TABLE foobar ( id INTEGER NOT NULL AUTO_INCREMENT, CONSTRAINT pk_foobar PRIMARY KEY (id) ) need a test case illustrating the failure. The main problem with this is that I can’t see a way to modify primary keys with alembic in a way

Re: [sqlalchemy] Unable to make referential integrity work

2015-04-10 Thread Mike Bayer
de return escape_str(value, mapping) File "C:\code-environs\iflask\lib\site-packages\pymysql-0.6.6-py2.7.egg\pymysql\converters.py", line 71, in escape_str return "'%s'" % escape_string(value, mapping) File "C:\code-environs\iflask\lib\site-packag

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

2015-04-09 Thread Mike Bayer
On 4/9/15 1:50 PM, Jacob Magnusson wrote: I have this case with a bundle that looks something like this: |primate_bundle = Bundle( 'primate', Primate.name, Bundle('wooden_tool', *[ WoodenTool.id, WoodenTool.name, WoodenToolCategory.name.label('category'), ]), Bundle('solid_tool', *[ SolidT

Re: [sqlalchemy] listening for events on 'mapper'

2015-04-08 Thread Mike Bayer
On 4/8/15 5:14 PM, Tim Tisdall wrote: I have some code I'm trying to figure out... Here it is: from sqlalchemy import event from colanderalchemy import setup_schema from sqlalchemy.orm import mapper event.listen(mapper, 'mapper_configured', setup_schema) It appears to call `setup_schema` o

Re: [sqlalchemy] updating a unicode column

2015-04-08 Thread Mike Bayer
On 4/8/15 9:38 PM, arash afshar wrote: I am calling commit, right after updated those two values. Any suggestion on what else to check? what is the exact column type given to this column, are there any event.listen() things going on, and also what does a repr() of the object's __dict__ look

Re: [sqlalchemy] updating a unicode column

2015-04-08 Thread Mike Bayer
On 4/8/15 9:16 PM, arash afshar wrote: When I try to update a row using ORM in the following way, it shows the following error: InterfaceError: (InterfaceError) Error binding parameter 0 - probably unsupported type. u'UPDATE table_name SET unicode_col=?, int_col=? WHERE table_name.id = ?' ((u

Re: [sqlalchemy] use of between() with Column.op()

2015-04-10 Thread Mike Bayer
On 4/10/15 10:23 PM, Horcle wrote: I really dig use of the column operator for constructing queries, but have been unsuccessful with using this when the argument is "between." I read somewhere that Column.op(var) when var = "in_" does not work, so I would assume that this is true with "betwee

Re: [sqlalchemy] GeoAlchemy2 mutation tracking on Geometry Column?

2015-04-13 Thread Mike Bayer
On 4/9/15 1:38 PM, joe meiring wrote: Is there some way to implement mutation tracking on a sqlalchemy2 Geometry (POLYGON) Column? Can I just wrap it in a MutableDict can I? I haven't worked with geoalchemy in many years, I'd advise just give it a try and/or dig into geoalchemy's source to

Re: [sqlalchemy] Decimals generated as strings in query

2015-04-13 Thread Mike Bayer
On 4/13/15 11:50 AM, Gabriel Becedillas wrote: Dear all, I have a table that has 2 numeric columns, and I'm writing a query that performs some arithmetic on the filter clause between those columns and a Decimal. The problem that I'm facing is that I don't get any results at all. After a whil

Re: [sqlalchemy] Decimals generated as strings in query

2015-04-13 Thread Mike Bayer
On 4/13/15 2:25 PM, Gabriel Becedillas wrote: Dear Michael, Thanks a lot for your reply. In trying to narrow the problem as much as possible, I missed something important in my example. I'm actually doing an UPDATE, not a SELECT. When I wrote 'I tried casting my decimals using sqlalcheme.cas

Re: [sqlalchemy] polymorphic inheritance and unique constraints

2015-04-13 Thread Mike Bayer
On 4/13/15 4:59 PM, Richard Gerd Kuesters | Pollux Automation wrote: well, this didn't work with upstream 1.0 - sorry, I was in another project and couldn't test it myself. you're not doing the same thing this user was doing in any case... Traceback (most recent call last): File "databa

Re: [sqlalchemy] "evaluate" strategy for a bulk delete seems to mishandle cases where column and attribute names differ

2015-04-14 Thread Mike Bayer
On 4/14/15 6:38 AM, Steven Winfield wrote: Hi, I think I've found a bug triggered by bulk deletes that use the (default) "evaluate" strategy. a bug is created at https://bitbucket.org/zzzeek/sqlalchemy/issue/3365/evaluator-cant-locate-orm-entity-when and for now you need to compare using

Re: [sqlalchemy] SQLAlchemy's merge doesn't fill foreign keys with ids of new objects in relationship

2015-04-14 Thread Mike Bayer
On 4/14/15 3:55 AM, Юрий Пайков wrote: My question is when I have in a session a newly created object(doesn't have primary key yet, but will obtain it upon flush) and I merge to that session another object referring to the first one by relationship (/b/ in the example) SQLAlchemy doesn't po

Re: [sqlalchemy] Not able to filter column by datetime

2015-04-15 Thread Mike Bayer
On 4/15/15 6:52 AM, Juan Antonio Ibáñez wrote: Hello, I have dozens of queries filtering DateTime columns but I have got one I don't know why it doesn't work. I have: --- q = DBSession.query(func.sum(RecargaCredito.importe), Local.nombre)\ .join((Local, Recarg

Re: [sqlalchemy] polymorphic inheritance and unique constraints

2015-04-15 Thread Mike Bayer
a better illustration with my actual code: http://pastebin.com/RxS8Lzft best regards, richard. On 04/13/2015 06:30 PM, Mike Bayer wrote: On 4/13/15 4:59 PM, Richard Gerd Kuesters | Pollux Automation wrote: well, this didn't work with upstream 1.0 - sorry, I was in another project

Re: [sqlalchemy] polymorphic inheritance and unique constraints

2015-04-15 Thread Mike Bayer
feature ... thanks for bring it on :) although, is there a way to use it in declarative, intead of: MyModel.__table__.add_is_dependent_on(MyParentModel.__table__) ? cheers, richard. On 04/15/2015 02:44 PM, Mike Bayer wrote: On 4/15/15 1:07 PM, Richard Gerd Kuesters wrote: ok, now i h

Re: [sqlalchemy] polymorphic inheritance and unique constraints

2015-04-15 Thread Mike Bayer
use it's difficult to relate things to a whole set of tables which each act as "the table" for a class. On 04/15/2015 03:13 PM, Richard Gerd Kuesters wrote: oh, right, concrete! abstract concrete can also do the trick? On 04/15/2015 03:10 PM, Mike Bayer wrote: On 4/15/

Re: [sqlalchemy] [SQLAlchemy 0.8.2 - NULL value support for version_id_col attribute in mapper()]

2015-04-15 Thread Mike Bayer
On 4/15/15 10:38 PM, Khoa Nguyen Minh wrote: Hi everyone, Could you please tell me whether SQLAlchemy 0.8.2 supports NULL value when using version_id_col? Currently, the correspond SQL emitted when updating/deleting is: *where [version_column] = NULL* * * That always raises StaleDataError

[sqlalchemy] SQLAlchemy 1.0.0 Released

2015-04-16 Thread Mike Bayer
Hello list ! It is my great pleasure to announce that SQLAlchemy release 1.0.0 is now available. Release 1.0.0 marks the tenth major SQLAlchemy series and occurs within the tenth year of the SQLAlchemy project overall; development started in 2005 and the release of 0.1.0 was in February of 2

Re: [sqlalchemy] The use of SQLAlchemy for a long term project

2015-04-18 Thread Mike Bayer
On 4/17/15 6:58 PM, Van Klaveren, Brian N. wrote: Hi, I'm investigating the use and dependency on SQLAlchemy for a long-term astronomy project. Given Version 1.0 just came out, I've got a few questions about it. 1. It seems SQLAlchemy generally EOLs versions after about two releases/years.

Re: [sqlalchemy] Generating Correlated Subqueries

2015-04-18 Thread Mike Bayer
On 4/18/15 7:13 PM, Michael Wilson wrote: I have the following tables: things_table = Table(’thing', self.metadata, Column('id', Integer, primary_key=True), … ) comments_table = Table('comments', self.metadata, Column('id', Integer, primary_key=True), # Unique id for this comment

Re: [sqlalchemy] Generating Correlated Subqueries

2015-04-19 Thread Mike Bayer
On 4/19/15 9:36 AM, ThereMichael wrote: Sorry, sometimes you get so deep into something you forget everyone else isn't familiar with the problem. As an example, here's what I'm looking for: select things.id, count(comments.type) from things things, comments comments where things.cre

Re: [sqlalchemy] Generating Correlated Subqueries

2015-04-19 Thread Mike Bayer
On 4/19/15 9:56 AM, Mike Bayer wrote: On 4/19/15 9:36 AM, ThereMichael wrote: Sorry, sometimes you get so deep into something you forget everyone else isn't familiar with the problem. As an example, here's what I'm looking for: select things.id, count(comments.ty

Re: [sqlalchemy] Recovering from StaleDataErrors

2015-04-19 Thread Mike Bayer
On 4/19/15 5:58 PM, George Reilly wrote: The aggregated centralized log looks like first interleaved request, 254c1046-0da701ca, at 19:09:03, which switches moods from `['Grumpy', 'Tired', 'Disgruntled']` to `['Elated']` Apr 15 19:09:03 [3843:MainThread] INFO [254c1046-0da701ca]

Re: [sqlalchemy] Generating Correlated Subqueries

2015-04-19 Thread Mike Bayer
On 4/19/15 10:16 AM, ThereMichael wrote: Ok, that worked perfectly! If I want /all/ of the "Thing" object, I change it to this: q = s.query(Thing, func.count(Comment.type)).\ filter(Thing.creation >= datetime.date(2015, 4, 19)).\ filter(Thing.creation < datetime.date(2015, 4, 26)).\

Re: [sqlalchemy] Non backwards-compatible changes in 1.0? Lots of suddenly failing tests here.

2015-04-20 Thread Mike Bayer
On 4/20/15 8:09 AM, Guido Winkelmann wrote: Hi, Have there been any non-backwards-compatible changes in SQLAlchemy 1.0 compared to 0.9.9? Most behavioral changes are listed out at http://docs.sqlalchemy.org/en/rel_1_0/changelog/migration_10.html; I've urged everyone to please read through t

Re: [sqlalchemy] Non backwards-compatible changes in 1.0? Lots of suddenly failing tests here.

2015-04-20 Thread Mike Bayer
On 4/20/15 8:09 AM, Guido Winkelmann wrote: Hi, Have there been any non-backwards-compatible changes in SQLAlchemy 1.0 compared to 0.9.9? We are seeing a lot of sudden breakage in our unit tests when switching to SQLAlchemy 1.0 from 0.9.9. Tests that worked fine before suddenly fail acros

Re: [sqlalchemy] Non backwards-compatible changes in 1.0? Lots of suddenly failing tests here.

2015-04-20 Thread Mike Bayer
On 4/20/15 12:56 PM, Guido Winkelmann wrote: I just tested, the problem is still present in the current master (bd61e7a3287079cf742f4df698bfe3628c090522 from github). Guido W. can you please try current master at least as of a3af638e1a95d42075e25e874746, thanks. -- You received this mess

Re: [sqlalchemy] Non backwards-compatible changes in 1.0? Lots of suddenly failing tests here.

2015-04-21 Thread Mike Bayer
On 4/21/15 6:45 AM, Guido Winkelmann wrote: On Monday 20 April 2015 21:57:40 Oliver Palmer wrote: [...] So I got to thinking about what we're doing differently with sqlite and this bit of code comes to mind: # sqlite specific configuration for development if db.engine.name == "sqlite

Re: [sqlalchemy] Can I restrict the set of mappers that configure_mappers() works on?

2015-04-21 Thread Mike Bayer
On 4/21/15 9:31 AM, Steven Winfield wrote: Hi, It seems like configuration is attempted for all new mappers, globally, whenever a query is done. So if library A and B both use sqlalchemy, and A imports B before A's mappers can be properly initialised (e.g. there is a relationship("Classname

Re: [sqlalchemy] Non backwards-compatible changes in 1.0? Lots of suddenly failing tests here.

2015-04-21 Thread Mike Bayer
On 4/21/15 11:19 AM, Guido Winkelmann wrote: On Tuesday 21 April 2015 09:43:51 Mike Bayer wrote: On 4/21/15 6:45 AM, Guido Winkelmann wrote: On Monday 20 April 2015 21:57:40 Oliver Palmer wrote: [...] So I got to thinking about what we're doing differently with sqlite and this bit of

Re: [sqlalchemy] Can I restrict the set of mappers that configure_mappers() works on?

2015-04-21 Thread Mike Bayer
On 4/21/15 12:25 PM, Steven Winfield wrote: OK, thanks for the quick answer - I guess I shouldn't be using sqlalchemy for the importer then, since this necessarily has to perform queries in order for scripts to be imported. what's that about ? some kind of dynamic scripting environment? If

Re: [sqlalchemy] pandas.DataFrame.to_sql method: how to speed up exporting to Microsoft SQL Server (6 minutes for 11 MB!)

2015-04-21 Thread Mike Bayer
On 4/21/15 1:47 PM, John Doe wrote: I am using pandas 0.16 and sqlalchemy 0.99. Yes, I know I should probably upgrade, but I don't have admin rights on my PC. I understand the pandas.DataFrame.to_sql() method relies on sqlalchemy. I have a pandas dataframe with ca 155,000 rows and 12 columns.

Re: [sqlalchemy] pandas.DataFrame.to_sql method: how to speed up exporting to Microsoft SQL Server (6 minutes for 11 MB!)

2015-04-22 Thread Mike Bayer
On 4/22/15 5:45 AM, John Doe wrote: Is there a way to output all the SQL statements into a file? I don't mean a logging file with other information, I mean a file with **only** SQL statements, which could ideally be run as it is from within my database client. Python logging will get you the

Re: [sqlalchemy] Non backwards-compatible changes in 1.0? Lots of suddenly failing tests here.

2015-04-22 Thread Mike Bayer
t 11:42:30 AM UTC-4, Michael Bayer wrote: On 4/21/15 11:19 AM, Guido Winkelmann wrote: > On Tuesday 21 April 2015 09:43:51 Mike Bayer wrote: >> On 4/21/15 6:45 AM, Guido Winkelmann wrote: >>> On Monday 20 April 2015 21:57:40 Oliver Palmer wrote: >>>

Re: [sqlalchemy] SQLAlchemy as plain-SQL generator

2015-04-22 Thread Mike Bayer
On 4/22/15 8:27 AM, Richard Gerd Kuesters wrote: hi, you must use a specific dialect so sqlalchemy can create it for you. not the best usage, imho, but here it goes: *stmt = query.compile().process(query, literal_binds=True)* OK since Pavel noted the double compile, if you want the litera

Re: [sqlalchemy] SAWarning: Unicode type received non-unicode bind param value

2015-04-22 Thread Mike Bayer
On 4/22/15 3:48 AM, Pavel S wrote: Hi, it happened to me many times during development, mainly when used custom column types, that I passed wrong type of value to the query. Then the the following warning was emitted:| || SAWarning: Unicodetype received non-unicode bindparam value | The pr

Re: [sqlalchemy] SAWarning: Unicode type received non-unicode bind param value

2015-04-22 Thread Mike Bayer
On 4/22/15 5:47 AM, Pavel S wrote: If I turn warnings into errors, the problem is still the same: 1) where the error occured as the code path in traceback is not pointing to the place where select() has been bound with values that would suggest your code has some less typical form where you a

Re: [sqlalchemy] pandas.DataFrame.to_sql method: how to speed up exporting to Microsoft SQL Server (6 minutes for 11 MB!)

2015-04-22 Thread Mike Bayer
On 4/22/15 10:11 AM, John Doe wrote: On Wednesday, April 22, 2015 at 2:46:19 PM UTC+1, Michael Bayer wrote: I carefully re-read your first email, and now I see, that you are trying to write *TO* the database, yes?And you're comparing the speed of writing *TO* to the spe

Re: [sqlalchemy] Non backwards-compatible changes in 1.0? Lots of suddenly failing tests here.

2015-04-22 Thread Mike Bayer
look at this. On Tuesday, April 21, 2015 at 11:42:30 AM UTC-4, Michael Bayer wrote: On 4/21/15 11:19 AM, Guido Winkelmann wrote: > On Tuesday 21 April 2015 09:43:51 Mike Bayer wrote: >> On 4/21/15 6:45 AM, Guido Winkelmann wrote: >>>

Re: [sqlalchemy] pandas.DataFrame.to_sql method: how to speed up exporting to Microsoft SQL Server (6 minutes for 11 MB!)

2015-04-22 Thread Mike Bayer
On 4/22/15 12:07 PM, John Doe wrote: On Wednesday, April 22, 2015 at 3:20:13 PM UTC+1, Michael Bayer wrote: a COMMIT every time would slow it down, yes, but then in your profiling you'd see the do_commit() method taking up that time as well. if you can get your logging goin

Re: [sqlalchemy] Non backwards-compatible changes in 1.0? Lots of suddenly failing tests here.

2015-04-22 Thread Mike Bayer
On 4/22/15 12:45 AM, Oliver Palmer wrote: We're using a Flask extension to work with sqlalchemy called flask-sqlalchemy. The engine is usually not directly exposed but echo can be enabled using a configuration var

[sqlalchemy] SQLAlchemy 1.0.1 Released

2015-04-23 Thread Mike Bayer
SQLAlchemy release 1.0.1 is now available. This is a quick bug-fix release that repairs several new regressions identified in the 1.0.0 release, not found during the beta period. All users of 1.0.0 are encouraged to upgrade to 1.0.1. Key elements of this release include fixes regarding the NE

Re: [sqlalchemy] Access __tablename__ in server_defaults?

2015-04-23 Thread Mike Bayer
if you are using __tablename__ what happens if you just refer to cls.__tablename__ in that method ? On 4/23/15 3:46 PM, Jacob Magnusson wrote: Would it somehow be possible to access the __tablename__ in server_default? What I'm looking for is something like this: |class PositionMixin(object

Re: [sqlalchemy] Add information to reflected tables

2015-04-23 Thread Mike Bayer
On 4/23/15 5:15 PM, Jeffrey Yan wrote: I have a couple of tables that I want to reflect. The first is a data table where one of the columns is a foreign key to the second table. If I used SQLAlchemy declarative_base, a query might look something like this: | session.query(Client.name,Subur

Re: [sqlalchemy] Re: H2 database

2015-04-24 Thread Mike Bayer
On 4/24/15 12:06 PM, Jonathan Vanasco wrote: SqlAlchemy needs 2 things for a database work: 1. A python database driver 2. A SqlAlchemy dialect (that tells SqlAlchemy how to write sql for the driver) So... 1. H2 doesn't seem to have any Python drivers or other support. I just came across

Re: [sqlalchemy] Making a new type out of Postgres DATERANGE + Psycopg2 DateRange

2015-04-24 Thread Mike Bayer
On 4/24/15 9:09 AM, Dimitris Theodorou wrote: Hi, I am using psycopg2 and trying to put together a new daterange type that combines the following: 1. A custom daterange class which provides various useful helpers (backwards/forwards iteration, intersection). 2. The psycopg2 DateRange that

Re: [sqlalchemy] Preserve mapped entities after wrapping the query

2015-04-24 Thread Mike Bayer
On 4/24/15 5:25 PM, Пайков Юрий wrote: q = session.query(Recipe, func.avg(Recipe.field1).over(...)).join(...) I have a query which selects some mapped entity as well as other columns. I then refer to the name of that entity when working with the result of the query: for entry in q.all(): reci

[sqlalchemy] SQLAlchemy 1.0.2 Released

2015-04-24 Thread Mike Bayer
SQLAlchemy release 1.0.2 is now available. As additional regressions are still being reported, we would like to get these changes out as fast as possible so that early adopters are working on a 1.0 version that is most representative of what its final form will be. 1.0.2 includes two additiona

Re: [sqlalchemy] Declarative setup failing on upgrade to 1.0.1

2015-04-24 Thread Mike Bayer
give 1.0.2 a try since we adjusted some things regarding __declare_first__ and __declare_last__. Further than that it depends a lot on what your basic "Base" setup looks like, mixins in use, extensions like AbstractConcreteBase, stuff like that. Any details you can share would help. On

Re: [sqlalchemy] Preserve mapped entities after wrapping the query

2015-04-25 Thread Mike Bayer
On 4/25/15 6:05 AM, Юрий Пайков wrote: Ok, I seemed to figure out how to deal with it - | row_number_column = func.row_number().over( partition_by=Recipe.id ).label('row_number') query = query.add_column( row_number_column ) query = query.from_self().filter(row_number_column == 1) | U

Re: [sqlalchemy] How can i use LIKE with an association proxy?

2015-04-27 Thread Mike Bayer
On 4/27/15 5:56 AM, Adrian wrote: In my user have I have an association proxy so I can access all email addresses of the user via User.all_emails. For a simple exact search I simply .filter(User.all_emails.contains('f...@example.com')). Is it also possible to use e.g. a LIKE match (besides m

Re: [sqlalchemy] when do I have to do a rollback so the app keep working fine

2015-04-27 Thread Mike Bayer
On 4/27/15 7:40 AM, David Allouche wrote: On 18 Apr 2015, at 02:20, dcgh...@gmail.com wrote: Hi everyone, I have a considerably amount of code that uses SQLAlchemy and I want to implement a decorator that captures the SQLAlchemy exceptions, then make session.rollback() and recall the decorat

Re: [sqlalchemy] How can i use LIKE with an association proxy?

2015-04-27 Thread Mike Bayer
On 4/27/15 1:52 PM, Adrian wrote: That's the first thing I've tried. Unfortunately it doesn't work... ---> 1 User.find_all(User.all_emails.any(UserEmail.email.like('%adrian%'))) wait, what is UserEmail, that's the association. This would be the endpoint class. Can you share all three c

Re: [sqlalchemy] before_create receives a list of tuples in the `tables` kwarg since 1.0

2015-04-27 Thread Mike Bayer
On 4/27/15 2:09 PM, Adrian wrote: I just tried updating from 0.9.9 to 1.0.2 and noticed that this code is now broken ("tuple object has no attribute schema"): def _before_create(target, connection, **kw): schemas = {table.schema for table in kw['tables']} for schema in schemas: Create

Re: [sqlalchemy] before_create receives a list of tuples in the `tables` kwarg since 1.0

2015-04-27 Thread Mike Bayer
On 4/27/15 2:43 PM, Mike Bayer wrote: On 4/27/15 2:09 PM, Adrian wrote: I just tried updating from 0.9.9 to 1.0.2 and noticed that this code is now broken ("tuple object has no attribute schema"): def _before_create(target, connection, **kw): schemas = {table.schema for t

Re: [sqlalchemy] polymorphic objects

2015-04-27 Thread Mike Bayer
On 4/27/15 4:31 PM, Richard Gerd Kuesters wrote: well, i'm having trouble dealing with polymorphic objects. i mean, the functionality is fine, i just don't know how to obtain the "main" object. let me be clear: i have A, which is my main object, and is inherited by B and C. I would like to w

Re: [sqlalchemy] Automap not reflecting tables in Postgres schemas

2015-04-27 Thread Mike Bayer
On 4/27/15 4:29 PM, Sam Zhang wrote: Hello, I'm following the documentation for reflecting database tables using `automap`: http://docs.sqlalchemy.org/en/latest/orm/extensions/automap.html#generating-mappings-from-an-existing-metadata. When I don't specific a schema, and Postgres uses the

Re: [sqlalchemy] Automap not reflecting tables in Postgres schemas

2015-04-28 Thread Mike Bayer
On 4/28/15 3:02 PM, Sam Zhang wrote: Thanks Michael! it was the lack of a primary key. I see references to it now that I know what to look for - a very interesting explanation: http://docs.sqlalchemy.org/en/latest/faq/ormconfiguration.html#how-do-i-map-a-table-that-has-no-primary-key - http:

Re: [sqlalchemy] How can i use LIKE with an association proxy?

2015-04-28 Thread Mike Bayer
First off, this is unusual because most people would just use the primary attribute, association proxy isn't buying you anything here: s.query(User).filter(User._all_emails.any(UserEmail.email.like('foo'))) vs. s.query(User).filter(User.all_emails.any(UserEmail.email.like('foo'))) same amou

Re: [sqlalchemy] [ORM] Fetching columns that were assigned a SQL expression as part of INSERT...RETURNING and UPDATE...RETURNING

2015-04-28 Thread Mike Bayer
use the eager_defaults flag: http://docs.sqlalchemy.org/en/rel_1_0/orm/mapping_api.html?highlight=eager_defaults#sqlalchemy.orm.mapper.params.eager_defaults http://docs.sqlalchemy.org/en/rel_0_9/changelog/migration_09.html#orm-can-efficiently-fetch-just-generated-insert-update-defaults-using-re

Re: [sqlalchemy] Why is an association object mark as "dirty" instead of "deleted" when removed?

2015-04-28 Thread Mike Bayer
On 4/28/15 6:57 PM, st...@canary.md wrote: Hi, Background information: I am trying to implement functionality similar to the history_meta.py example (http://docs.sqlalchemy.org/en/rel_0_9/_modules/examples/versioned_history/history_meta.html). I am listening for after_flush events and creat

Re: [sqlalchemy] Automap not reflecting tables in Postgres schemas

2015-04-28 Thread Mike Bayer
On 4/28/15 10:08 PM, Sam Zhang wrote: Just hit the issue tracker with this, and the two snags I encountered so far doing this. Hopefully it's not because I missed some glaring instructions about how to build the documentation? there's no instructions right now. it's a sphinx build, plus the t

Re: [sqlalchemy] column_descriptions on recursive query : AttributeError: 'CTE' object has no attribute 'entity'

2015-04-29 Thread Mike Bayer
On 4/29/15 5:16 AM, g wrote: Hi all I have a query like that from sqlalchemy.orm import aliased class Part(Base): __tablename__ = 'part' part = Column(String, primary_key=True) sub_part = Column(String, primary_key=True) quantity = Column(Integer) included_p

Re: [sqlalchemy] SA 1.0.2 throwing TypeError: Boolean value of this clause is not defined

2015-04-29 Thread Mike Bayer
On 4/29/15 9:25 AM, Bill Schindler wrote: This error is being thrown on code that worked with 0.9.8. It seems to be checking a comparison on something, but I can't figure out which "this clause" the exception is referring to. Here's the stripped-down code leading up to the commit: ancie

  1   2   3   4   5   6   7   8   9   10   >