[sqlalchemy] Re: this is a test message

2023-01-04 Thread Michael Bayer
this is...another test! imagine that On Wednesday, January 4, 2023 at 7:27:10 PM UTC-5 Mike Bayer wrote: > test > -- 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 E

[sqlalchemy] Re: after_update event is fired when I save a many-to-many relationship

2023-01-04 Thread Michael Bayer
the net-change to "user1.teams" is likely sending it through the "after_update" event but no net SQL is being emitted if no actual columns have changed on user1. you would need to adjust the logic in your application to more specifically check for those conditions in which you want to act upon

[sqlalchemy] Re: How to generate view columns in mapped class with async postgresql

2023-01-04 Thread Michael Bayer
the async aspect here is not that important, for Declarative + reflection you likely should look at DeferredReflection: https://docs.sqlalchemy.org/en/14/orm/declarative_tables.html#using-deferredreflection for async, where it has in the example: Reflected.prepare(engine) you would instead say

[sqlalchemy] Re: SQLAlchemy with MySQL on AWS Lambda is taking long time to truncate table

2023-01-04 Thread Michael Bayer
is truncate happening in some other process? does it speed up once you kill the initial python process? does this truncate take time with other kinds of INSERT statements? is the table very large? overall you need to perform more observations here as to what conditions cause this "trunc

[sqlalchemy] Re: getting raw of the query

2023-01-04 Thread Michael Bayer
using logging is the most direct way, however if you want to programmatically intercept all SQL you can use before_cursor_execute: https://docs.sqlalchemy.org/en/14/core/events.html#sqlalchemy.events.ConnectionEvents.before_cursor_execute On Thursday, December 8, 2022 at 9:31:56 AM UTC-5 yahme..

[sqlalchemy] Re: Does SQLAlchemy Core support MERGE?

2023-01-04 Thread Michael Bayer
we don't support the SQL standard MERGE directly right now but you can always emit this statement using text(). We support only the MySQL / PostgreSQL / SQlite driver specific INSERT..ON CONFLICT kinds of statements directly right now. On Sunday, December 11, 2022 at 11:34:43 AM UTC-5 mkmo...

[sqlalchemy] Re: load_only when loading relatinoships from an instance

2023-01-04 Thread Michael Bayer
yeah you can use defaultload.load_only defaultload(ModelA.model_b).load_only(ModelB.only_field) On Wednesday, January 4, 2023 at 3:15:02 AM UTC-5 to...@revenuecat.com wrote: > Hi, > > This might be a strange question, but I tried to find this in the > documentation to no avail. > > Is it po

[sqlalchemy] Re: best way to declare one-to-one relationships with automap and non-explicit relationships

2016-02-14 Thread Michael Bayer
On Sunday, February 14, 2016 at 4:12:36 PM UTC-5, Brian Cherinka wrote: > > Hi, > > I'm trying to use automap a schema, and let it generate all classes and > relationships between my tables. It seems to work well for all > relationships except for one-to-one > I know to set a one-to-one rela

Re: [sqlalchemy] Use order_by when using relationship() with secondary-parameter in a many-to-many?

2016-02-14 Thread Michael Bayer
order_by, you spelled it wrong. > On Feb 14, 2016, at 3:53 AM, wrote: > > Hi Mike > >> On 2016-02-13 14:30 Mike Bayer wrote: >> you can order by secondary, just add it in: >> >> authors = relationship("Person", secondary=ReferenceAuthor, >> order_by=ReferenceAuthor.c.Index) > > Are you sur

Re: [sqlalchemy] AttributeError thrown by relationship during unit testing

2016-01-12 Thread Michael Bayer
Two options - either use back_populates format (search the docs) to set up bidirectional relationships, or call configure_mappers() after the model classes have been defined. > On Jan 11, 2016, at 3:47 PM, Sam Raker wrote: > > Using SQLAlchemy 1.0.9's declarative extension, I've got a many-

Re: [sqlalchemy] AttributeError thrown by relationship during unit testing

2016-01-12 Thread Michael Bayer
Sent from my iPhone > On Jan 11, 2016, at 3:47 PM, Sam Raker wrote: > > Using SQLAlchemy 1.0.9's declarative extension, I've got a many-to-one > relationship defined thusly: > > class Article(Base): >... >publisher_id = schema.Column(sqltypes.Integer, > schema.ForeignKey('publishers

Re: [sqlalchemy] combining column_property and TypeDecorator

2015-11-10 Thread Michael Bayer
Look into the type_coerce() function for that. > On Nov 10, 2015, at 5:46 PM, Uri Okrent wrote: > > Seems like a simple thing to do but I can't seem to find an example. Say I > have a simple column_property like the example in the docs: > > fullname = column_property(firstname + " " + lastnam

Re: [sqlalchemy] combining column_property and TypeDecorator

2015-11-10 Thread Michael Bayer
Sent from my iPhone > On Nov 10, 2015, at 5:46 PM, Uri Okrent wrote: > > Seems like a simple thing to do but I can't seem to find an example. Say I > have a simple column_property like the example in the docs: > > fullname = column_property(firstname + " " + lastname) > > > and I want to

Re: [sqlalchemy] 10 Reasons to love SQLAlchemy

2015-09-07 Thread Michael Bayer
Thanks very much for this post, Paul! Sent from my iPhone > On Sep 4, 2015, at 3:43 PM, Paul Johnston wrote: > > Hi guys, > > I decided to express my love of SQLAlchemy through a blog post: > http://pajhome.org.uk/blog/10_reasons_to_love_sqlalchemy.html > > Enjoy, > > Paul > -- > You receiv

Re: [sqlalchemy] create/restore a dump-file

2015-06-20 Thread Michael Bayer
> On Jun 20, 2015, at 10:40 AM, (by way of c.bu...@posteo.jp) > wrote: > > I read about the Serializer Extension and ask myself if it is a good > solution for my problem. Haven't even read the rest of your email yet, and the answer is no. The serializer works really badly. > > Current

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

2015-04-20 Thread Michael Bayer
> On Apr 20, 2015, at 12:56 PM, Guido Winkelmann > wrote: > >> On Monday 20 April 2015 11:23:06 Mike Bayer wrote: >> On 4/20/15 8:09 AM, Guido Winkelmann wrote: > [...] >>> On sqlite, drop_all() seems to fail to get the order of table drops >>> right, and consequently runs into a referential

Re: [sqlalchemy] Documentation for SQLAlchemy 0.4.5?

2015-04-16 Thread Michael Bayer
If you go to pypi and actually download the 0.4.5 tar.gz file from the sqlalchemy project and expand it, the documentation will be there in html form in the doc/ directory.All sqlalchemy releases include an html build of the documentation in this directory in the source distribution. Sent f

Re: [sqlalchemy] Inherited class column override

2015-03-31 Thread Michael Bayer
e tradeoff here is basically between “more work with SQLAlchemy” vs. “not possible at all with other ORMs” :) The relational model is the more rigid part of the system here, so you have to work that part out first; then determine how you want to map the Python object model on top of the relational m

Re: [sqlalchemy] Postgres JSON/JSONB column NULL or null or None

2015-03-31 Thread Michael Bayer
joe meiring wrote: > So I've got a model like such and using sqlalchemy v0.9.8 > > class myModel(Base): > > > id > = Column(Integer, primary_key=True) > > border > = Column(JSONB) > How can I query for rows that don't have a border? I've tried: > > filter(myModel.border != None)

Re: [sqlalchemy] Inherited class column override

2015-03-31 Thread Michael Bayer
object make that work completely, with the more verbose use pattern. then when that is totally working and understood, then move onto association proxy: http://docs.sqlalchemy.org/en/rel_0_9/orm/extensions/associationproxy.html > On Tuesday, March 31, 2015 at 4:11:51 PM UTC+2, Michael Bayer w

Re: [sqlalchemy] Custom Type - two classes (object + TypeDecorator) or one (TypeDecorator)?

2015-03-31 Thread Michael Bayer
Jeffrey McLarty wrote: > Hello, > > First - amazing work on SQLAlchemy, what an amazing body of work. > > Second, my question. > > I'm attempting to convert a pure-python object, into a custom type for column > definition. My question is, do I need to keep my original MyObj(object) and > u

Re: [sqlalchemy] SQLAlchemy core what's the "right" find if row with primary key exists

2015-03-31 Thread Michael Bayer
Duke Dougal wrote: > I'm trying to find if a row with a given primary key exists. > > Is this the "right" way to do it? it looks fine and if you’re just starting out, by all means do what works and makes sense to you. > I'm using Python 3.4 and Sqlite 3.8.2 > > > from sqlalchemy.ext.automa

Re: [sqlalchemy] Thread safety - is it safe to use the core in a web application?

2015-03-31 Thread Michael Bayer
Duke Dougal wrote: > I am using the Falcon web server and SqlAlchemy core. > > I have read warnings about it not being thread safe. > > I'm not sure what the implications are of this. Will there be a problem or > can I code around it somehow? > > I'm trying to avoid the ORM for now - at le

Re: [sqlalchemy] Inherited class column override

2015-03-31 Thread Michael Bayer
; secondaryjoin='and_(MySubClass1.type == 802, MySubClass1.id1 == > Left.id)' > ) > > class Left(db.Model): > id = db.Column(db.Integer, primary_key=True) > > MyClass is used as a junction table for a bunch of different relationships, > t

Re: [sqlalchemy] Can't upgrade SQLAlchemy any more

2015-03-31 Thread Michael Bayer
Sibylle Koczian wrote: > Am 29.03.2015 um 22:47 schrieb Werner: >> Had similar issue with wxPython-Phoenix and pip with 3.4.0 was very far >> behind, don't know about 3.4.3. >> >> pip 6.0.8 and setuptools 12.2 fixed it for me > > pip 6.0.8 was installed, setuptools was on 12.0.5, same as on m

Re: [sqlalchemy] select x for update is still snapshot read in sqlalchemy.

2015-03-31 Thread Michael Bayer
ying zhang wrote: > > > I'm confused with how Query.with_lockmode('update') works in sqlalchemy. > My code is in attachment. > For testing, I start test.py in 1st terminal, then start test.py in 2nd > terminal. > so the 2nd termial will read the data modified by 1st test.py. > But the 2nd te

Re: [sqlalchemy] is it possible to turn off DELETE cascades globally for a session?

2015-03-30 Thread Michael Bayer
it’s not an option available at the moment, though there might be ways to avoid the collection loads (artificially zeroing them out w/o history). if you don’t need the relationship features then you might as well just use query.delete(). Jonathan Vanasco wrote: > I'm running a migration scr

Re: [sqlalchemy] Inherited class column override

2015-03-30 Thread Michael Bayer
Pierre B wrote: > Hi all, > > I'm ultimately trying to have different default values for the same column. > Following the documentation, the @declared_attr.cacading decorator seems to > be the best approach. > Here's my code: > class HasSomeAttribute(object): > @declared_attr.cascading >

[sqlalchemy] SQLAlchemy 1.0.0b4 released

2015-03-29 Thread Michael Bayer
SQLAlchemy release 1.0.0b4 is now available. This release contains a handful of fixes and enhancements mostly to address issues that were reported by beta testers. Things are looking very good and it's hoped that *maybe* this will be the last beta, unless a host of new regressions are reported.

Re: [sqlalchemy] Can't upgrade SQLAlchemy any more

2015-03-29 Thread Michael Bayer
this is a pip issue; first ensure you’re on the latest version of pip. If the error persists, please report it to https://github.com/pypa/pip/issues. Sibylle Koczian wrote: > Hello, > > I can't upgrade SQLAlchemy any more on just one of several Windows PCs. > Windows version is Windows 7 S

Re: [sqlalchemy] Process UNION results

2015-03-26 Thread Michael Bayer
I’d probably try to order_by(text(“union_date”)) so that it isn’t interpreted as a column object. If that doesn’t work, then the query here should use a simple Core union object, and then a new query session.query(my_union.c.union_date).distinct().order_by(my_union.c.union_date). pidev...@gmai

Re: [sqlalchemy] Is it possible to add another criterion to this backref?

2015-03-25 Thread Michael Bayer
Im trying to avoid having to write a full example for you from scratch so if you could provide everything in one example, both models and where you want the relationships, with all the columns, we can work from there, thanks. Adrian wrote: > In case it's unclear what exactly I'm trying to do, h

Re: [sqlalchemy] Can't figure out multiple level secondary join

2015-03-24 Thread Michael Bayer
Andrew Millspaugh wrote: > > I'm pretty inexperienced with SQLAlchemy. I mostly want to know the best way > to deal with a relationship like this. I am trying to avoid adding a fake > relationship directly between F and A, as it could get out of sync with the > actual nested relationship. I

Re: [sqlalchemy] Can't figure out multiple level secondary join

2015-03-24 Thread Michael Bayer
e docs works (I think). > > On Tuesday, March 24, 2015 at 4:47:42 PM UTC-7, Michael Bayer wrote: > > > Andrew Millspaugh wrote: > > > Yes, I got the style from there. > > > > I have a great great great great grandchild that I need to be able to

Re: [sqlalchemy] polymorphic inheritance and unique constraints

2015-03-24 Thread Michael Bayer
if yes, my problem is solved :) > > > On 03/24/2015 10:33 AM, Michael Bayer wrote: >> Richard Gerd Kuesters | Pollux >> >> wrote: >> >> >>> hi all! >>> >>> i'm dealing with a little problem here. i have a parent table and

Re: [sqlalchemy] Can't figure out multiple level secondary join

2015-03-24 Thread Michael Bayer
C.b, B.a) then: F.query.join(*F.join_to_a()) > > On Tuesday, March 24, 2015 at 6:28:31 AM UTC-7, Michael Bayer wrote: > > > Andrew Millspaugh wrote: > > > I've got a class hierarchy that looks something like this: > > > > [ A ] 1---

Re: [sqlalchemy] Is it possible to add another criterion to this backref?

2015-03-24 Thread Michael Bayer
Adrian wrote: > > the model here doesn’t illustrate how this would be a many-to-many. > A User can have any number of other Users as a favorite. That looks quite > many-to-many to me…. then you are referring to a self-referential User -> favorite_user -> User relationship which is M2M but th

Re: [sqlalchemy] Is it possible to add another criterion to this backref?

2015-03-24 Thread Michael Bayer
Adrian wrote: > @declared_attr > def user(cls): > """The user owning this favorite""" > return db.relationship( > 'User', > lazy=False, > foreign_keys=lambda: [cls.user_id], > backref=db.backref( > '_favorit

Re: [sqlalchemy] Is it possible to add another criterion to this backref?

2015-03-24 Thread Michael Bayer
ThiefMaster wrote: > The is_deleted column is in the User table. If possible I'd rather avoid > having to replicate it in the favorite tables (hard-deleting favorites is > fine, I only need soft deletion for users). the column can be on either side. I think maybe you want to illustrate the

Re: [sqlalchemy] Is it possible to add another criterion to this backref?

2015-03-24 Thread Michael Bayer
ThiefMaster wrote: > Hi, > > I have the following models for a "favorite" system: > > https://gist.github.com/ThiefMaster/e4f622d54c74ee322282 > > Now I'd like to restrict the relationship that's created by the backref in > L24, so it doesn't include any favorited users which have the is_de

Re: [sqlalchemy] Adding a listener on a backref

2015-03-24 Thread Michael Bayer
/backref.html. > Le mardi 24 mars 2015 14:23:00 UTC+1, Michael Bayer a écrit : > the “user” backref here is a relationship() like any other, just specify > Address.user as the target of the event. > > Cyril Scetbon wrote: > > > Hi, > > > > Is there a way

Re: [sqlalchemy] polymorphic inheritance and unique constraints

2015-03-24 Thread Michael Bayer
Richard Gerd Kuesters | Pollux wrote: > hi all! > > i'm dealing with a little problem here. i have a parent table and its two > inheritances. there is a value that both children have and must be unique > along either types. is there a way to move this column to the parent and use > a constr

Re: [sqlalchemy] Can't figure out multiple level secondary join

2015-03-24 Thread Michael Bayer
Andrew Millspaugh wrote: > I've got a class hierarchy that looks something like this: > > [ A ] 1* [ B ] 1-* [ C ] 1--* [ D ] 10..1 [ E > ] 1..*--0..1 [ F ] > > orgprojticketsnap > bidl

Re: [sqlalchemy] Adding a listener on a backref

2015-03-24 Thread Michael Bayer
the “user” backref here is a relationship() like any other, just specify Address.user as the target of the event. Cyril Scetbon wrote: > Hi, > > Is there a way to add an event listener on a backref ? > > I have something like : > > class User(Base): > > > __tablename__ = 'user' > >

Re: [sqlalchemy] sqlalchemy (0.9.7) double quoting python list items when used in "where in" statement

2015-03-23 Thread Michael Bayer
Edgaras Lukoševičius wrote: > A quick script with SQL table schema. won’t work with MySQL. The ability to send a pure string SQL statement directly to execute() in conjunction with a straight tuple, and have it magically expand out to an IN, is a psycopg2 / postgresql specific feature. > If t

Re: [sqlalchemy] Guaranteeing same connection for scoped session

2015-03-23 Thread Michael Bayer
Kent wrote: > In cases where we interact with the database session (a particular > Connection) to, for example, obtain an application lock which is checked out > from database for the lifetime of the database session (not just the duration > of a transaction), it is important that I guarante

Re: [sqlalchemy] auto column naming (declarative)

2015-03-23 Thread Michael Bayer
the before_parent_attach() event could do this, sure. Might be a little tricky: http://docs.sqlalchemy.org/en/rel_0_9/core/events.html?highlight=before_parent_attach#sqlalchemy.events.DDLEvents.before_parent_attach Richard Gerd Kuesters | Pollux wrote: > hi all! > > i remember bumping into th

Re: [sqlalchemy] Connections and the session

2015-03-21 Thread Michael Bayer
dcgh...@gmail.com wrote: > Hello there, > > I have the following code structure (more or less) in several processes: > > from sqlalchemy import create_engine > from sqlalchemy.orm import sessionmaker > > engine = create_engine(some_mysql_dburi) > session = sessionmaker(bind=engine)() > > wh

Re: [sqlalchemy] SQLAlchemy 1.0.0b2 released

2015-03-20 Thread Michael Bayer
Jonathan Vanasco wrote: > Wow. This is noticeably faster. that’s good to hear, I was able to chip away at overhead in many areas though most are relatively small. > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe fro

[sqlalchemy] SQLAlchemy 1.0.0b3 released

2015-03-20 Thread Michael Bayer
SQLAlchemy release 1.0.0b3 is now available. This is an emergency re-release of 1.0.0b2 to repair an erroneous commit, regarding the MySQL “utf8mb4” fix which was inadvertently commented out. Download 1.0.0b3 at: http://www.sqlalchemy.org/download.html -- You received this message because y

[sqlalchemy] SQLAlchemy 1.0.0b2 released

2015-03-20 Thread Michael Bayer
SQLAlchemy release 1.0.0b2 is now available. This is the second pre-release in the 1.0.0 series which includes a small handful of regression fixes and some additional features. We'd like to thank those who have been beta testing the 1.0.0 series and encourage all beta testers to upgrade to beta2!

Re: [sqlalchemy] ORM general concept question (how to combine all stuff together?)

2015-03-20 Thread Michael Bayer
two-man army. Here at SQLAlchemy Inc. we try to always have a satisfied customer! (if at all possible). > Again, thank you. > > > Ivan. > > > > > On Friday, March 20, 2015 at 1:30:19 AM UTC+2, Michael Bayer wrote: > > > Ivan Evstegneev wrote: > > >

Re: [sqlalchemy] How to output SQLAlchemy logger only to a file?

2015-03-19 Thread Michael Bayer
r...@rosenfeld.to wrote: > From what I read in the SQLAlchemy logging configuration documentation, I > understood that the echo argument on sqlalchemy.create_engine controls > whether sqlalchemy logging is forced to stdout, but shouldn't affect whether > log messages are available to log hand

Re: [sqlalchemy] ORM general concept question (how to combine all stuff together?)

2015-03-19 Thread Michael Bayer
Ivan Evstegneev wrote: > Hello, > > > First of all I'm new to DBs so please don't hang me on a tree ))) > > > I have basic and simple questions(at least it simple for me ^_^ ). > > While googling and reading some tutorials about ORM DBs at whole, I still > cannot build up a logical pictur

Re: [sqlalchemy] Tests hang at test_ora8_flags

2015-03-19 Thread Michael Bayer
Tony Locke wrote: > Hi, I've encountered a glitch when running py.test over the entire test suite > with the postgresql+pg8000 dialect: > > py.test --dburi postgresql+pg8000://postgres:xxx@localhost:5436/test > > the test hangs at: > > test/dialect/test_oracle.py::CompatFlagsTest::test_ora8

[sqlalchemy] Alembic 0.7.5 released

2015-03-19 Thread Michael Bayer
Hey all - Alembic 0.7.5 is now available. This release has a handful of bug fixes and some new features. Changelog is available at: http://alembic.readthedocs.org/en/latest/changelog.html#change-0.7.5 Download Alembic 0.7.5 at: https://pypi.python.org/pypi/alembic/0.7.5.post1 Note th

Re: [sqlalchemy] select_from() and single table inheritance

2015-03-19 Thread Michael Bayer
Julio César Gázquez wrote: > Hi. > > I have an inheritance hierarchy on the form, C inherits B (with single table > inheritance), B inherits A (with joined table inheritance). > > The next query works perfectly: > > session.query(C)\ >.join(C.related_objects) >.filter( ... ) # Unre

Re: [sqlalchemy] JSONB double casting

2015-03-18 Thread Michael Bayer
Brian Findlay wrote: > I'm having some difficulty using SQLAlchemy's jsonb operators to produce my > desired SQL. > > Intended SQL: > > SELECT * > FROM foo > WHERE foo.data->'key1' ? 'a' > > ...where `foo.data` is formatted like this: > > { > 'key1': ['a', 'b', 'c']

Re: [sqlalchemy] Loading of dependent objects performance issue

2015-03-17 Thread Michael Bayer
Cyril Scetbon wrote: > Hi, > > After having read > http://docs.sqlalchemy.org/en/latest/orm/loading_relationships.html I > understand there is one case where SQL is not emitted and I was expecting > that my case was this one. > > I use polymorphism to store different objects in the same ta

Re: [sqlalchemy] unhandled data type cx_Oracle.LOB

2015-03-16 Thread Michael Bayer
se exc.ResourceClosedError("This result object is closed.") > sqlalchemy.exc.ResourceClosedError: This result object is closed. > > > As long as I can check that resultset is empty and break from the loop, I am > fine. Any better way of handling this? That’s a bug in the or

Re: [sqlalchemy] unhandled data type cx_Oracle.LOB

2015-03-16 Thread Michael Bayer
ctly, SQLAlchemy’s result proxy works around that issue also, by fetching rows in chunks and converting the LOB objects to strings while they are still readable, so you could keep with the fetchmany() calls. > > Thank you for your help! > GP > > On Monday, March 16, 2015 at 5:

Re: [sqlalchemy] unhandled data type cx_Oracle.LOB

2015-03-16 Thread Michael Bayer
GP wrote: > So that's what was happening: > > This select construct fails: > select_query = select() > select_query.append_column(contract_id) > select_query.append_column(cancel_dt) > select_query.append_column(cancellation_obj) > select_query.append_from(source_table_name) > > > But this s

Re: [sqlalchemy] unhandled data type cx_Oracle.LOB

2015-03-16 Thread Michael Bayer
GP wrote: > Hello, > > While trying to insert into an Oracle table with one column defined as CLOB, > I get the following error: > File > "/home/x/.local/lib/python3.4/site-packages/sqlalchemy/engine/default.py", > line 442, in do_execute > cursor.execute(statement, parameters) > sq

Re: [sqlalchemy] deferred groups

2015-03-16 Thread Michael Bayer
g(255)) >> description = deferred( >> Column(Text()), >> group="full" >> ) >>type_ = Column( String(30), nullable=False) >> """ >> >> and a child model >> """ >> class Element(DBB

Re: [sqlalchemy] deferred groups

2015-03-16 Thread Michael Bayer
tonthon wrote: > Sorry I was a bit too speed when writing that one :) > > So I've got a Base model : > """ > class Base(DBBASE): >__tablename__ = > 'base' >__mapper_args__ = {'polymorphic_identity': 'base', 'polymorphic_on': > 'type_

Re: [sqlalchemy] deferred groups

2015-03-16 Thread Michael Bayer
tonthon wrote: > Hi, > > I'm using polymorphism and I set up some deferred columns at each level > of inheritance belonging to the same deferred group : > > """ > class Base(DBBASE): >id = Column(Integer, primary_key=True) >name = Column(String(255)) >description = deferred( >

[sqlalchemy] SQLAlchemy 1.0.0b1 released

2015-03-13 Thread Michael Bayer
Hey list - I’m very pleased to announce SQLAlchemy’s first foray into the world of “1.0”, which is our 1.0.0b1 release. As 1.0.0b1 includes “b1”, this is a “beta” release, intended for widespread evaluation. Assuming you’re all using a modern version of pip, it should not install automatically un

Re: [sqlalchemy] duplicate an object

2015-03-13 Thread Michael Bayer
moon...@posteo.org wrote: > On 2015-03-12 09:53 Michael Bayer wrote: >> which is why, “copy an object” is not an out of the box thing. Because >> nobody really wants a full “copy”, it’s something custom. > > As I described I don't want a "full copy".

Re: [sqlalchemy] postgres schemas at runtime

2015-03-12 Thread Michael Bayer
Francesco Della Vedova wrote: > Hello, > > I have a set of models that I would like to replicate on different Postgres > schemas. The name of the schema is only known at runtime. > Just as an example, imagine I have a bunch of tables of customer data, and I > want to create a schema 'custo

Re: [sqlalchemy] duplicate an object

2015-03-12 Thread Michael Bayer
moon...@posteo.org wrote: > On 2015-03-08 11:17 Michael Bayer wrote: >> there’s no particular “SQLAlchemy way” to do this, > > What is about > make_transient() > ? > > I don't understand this function 100%tly. it changes the state of an object from per

Re: [sqlalchemy] relationship problem

2015-03-12 Thread Michael Bayer
Julien Cigar wrote: > > Hi Mike, > > Sorry to bother you once with this, but I've re-read all the docs on > the relationships and I want to be sure that I've understand correctly. > > Imagine I have the following "link" table in SQL: > https://gist.github.com/silenius/77d406f8e0c0e26eb38f wi

Re: [sqlalchemy] duplicate an object

2015-03-12 Thread Michael Bayer
moon...@posteo.org wrote: > On 2015-03-08 11:17 Michael Bayer wrote: >> new_obj = MyClass() >> for attr in mapper.attrs: >>setattr(new_obj, attr.key, getattr(old_obj, attr.key)) > > This would copy everything including primary keys and unique members. which

[sqlalchemy] SQLAlchemy 0.9.9 Released

2015-03-10 Thread Michael Bayer
SQLAlchemy release 0.9.9 is now available. Release 0.9.9 is a large maintenance release featuring 30 changes, mostly bug fixes. A handful of modest feature adds are also present, including new Core features for SQLite, Postgresql, and new API features to provide better control of transaction isola

Re: [sqlalchemy] Database session variables with connection pooling

2015-03-09 Thread Michael Bayer
But, once I know that within > before_cursor_execute, can I (recursively) issue an conn.execute() for that > statement safely or will it affect the original execute? if you stick with the DBAPI connection directly then you’re definitely safe. > > > > On Saturday, March 7, 2

Re: [sqlalchemy] duplicate an object

2015-03-08 Thread Michael Bayer
moon...@posteo.org wrote: > On 2015-03-07 03:17 wrote: >> Is there a in-build-function to duplicate the instance of a data >> object (except the primary key)? > > Isn't there a way for this? > > Does the sqla-devs reading this list? there’s no particular “SQLAlchemy way” to do this, there’s

Re: [sqlalchemy] Database session variables with connection pooling

2015-03-07 Thread Michael Bayer
Kent wrote: > I'm implementing database session variables (in Oracle, > DBMS_SESSION.SET_CONTEXT(...)), in order to be able to set (from sqlalchemy) > and retrieve (from a database trigger) the application userid and URL path > during table audit triggers. > > The tricky bit is that if I se

Re: [sqlalchemy] Complicated self join

2015-03-05 Thread Michael Bayer
Dani Hodovic wrote: > I've been struggling with a query that gets the most recent date as described > here: http://stackoverflow.com/a/123481/2966951 > > I've been able to produce a SQLAlchemy variant, but it seems to be MUCH > slower when executed with MySQL. It also looks slightly differen

Re: [sqlalchemy] Re: Flushed PickleType data disappearing

2015-03-03 Thread Michael Bayer
SQLRook wrote: > To move one step from your sample toward my codebase, I made a class method > to modify the pickled list. Already, I see behavior that I cannot explain. > If the session is passed to modifyTarget(), you can observe the > targetInstance become dirty, marked as modified, and

Re: [sqlalchemy] Unicode String Error on Insert

2015-03-03 Thread Michael Bayer
J.D. wrote: > My solution didn't work. I was able to get my Portuguese data to load by > decoding it in ISO-8859-1, but by decoding I lose all the special characters > like tildes. > > So I still don't understand how to get the engine to accept my data properly. > > J.D. > > On Tuesday, Ma

Re: [sqlalchemy] Relationship behavior change when switching from reflected to declarative styles; test case included

2015-03-03 Thread Michael Bayer
Evan James wrote: > Hi folks, > > I'm working on a SQLAlchemy-based app where we've decided to make some > infrastructure changes, in particular moving from reflection to declaration > for mapping the models. > > However, we're now running into issues where, after switching to declarative,

Re: [sqlalchemy] Connection pooling strategy for a small/fixed number of db users

2015-03-03 Thread Michael Bayer
Russ wrote: > What is the recommended way to handle connection pooling when there will be a > small fixed set of database users (eg: 2) connecting? > > For example, the two users may be: > > `app`: the main user used by the application with full r/w privs > `readonly`: limited SELECT-only us

Re: [sqlalchemy] Flushed PickleType data disappearing

2015-03-03 Thread Michael Bayer
_modified(targetInstance) e = create_engine("sqlite://", echo=True) Base.metadata.create_all(e) s = Session(e) run(s) s.commit() s = Session(e) assert s.query(Target.targetList).scalar() == [4, 5, 6] > > > On Saturday, February 28, 2015 at 11:17:28 AM UTC-5, Michael Bayer

Re: [sqlalchemy] relationship problem

2015-03-02 Thread Michael Bayer
Julien Cigar wrote: > On Sun, Mar 01, 2015 at 01:53:30PM +0100, Julien Cigar wrote: >> On Fri, Feb 27, 2015 at 11:38:05PM -0500, Michael Bayer wrote: >>>> On Feb 26, 2015, at 5:56 AM, Julien Cigar wrote: >>>> >>>>> On Wed, Feb 2

Re: [sqlalchemy] session.transaction / session.begin and always rolling back

2015-03-02 Thread Michael Bayer
Jonathon Nelson wrote: > For a variety of reasons, sometimes it's nice to be able to do something like > this: > > with dbsess.begin(rollback=True): >do_stuff > > Where the expected behavior is that everything in the context runs in a > transaction, but upon exiting the context we issue

Re: [sqlalchemy] Unexpected is_modified result after referencing a relationship

2015-02-28 Thread Michael Bayer
ersions of the APIs right now would involve aggregating changes across flushes, probably using flush events. > --Eric > > On Fri, Feb 27, 2015 at 9:17 PM, Michael Bayer > wrote: > > > > On Feb 27, 2015, at 4:48 PM, Eric Smith wrote: > >> To those more exper

Re: [sqlalchemy] Flushed PickleType data disappearing

2015-02-28 Thread Michael Bayer
SQLRook wrote: > I'm having an issue where a list of user-defined objects is disappearing as a > function goes out of scope. The list is stored in a PickleType column, and > as that type does not track changes in the objects of the list, I am > (knowingly, inefficiently) forcing the column

Re: [sqlalchemy] relationship problem

2015-02-27 Thread Michael Bayer
> On Feb 26, 2015, at 5:56 AM, Julien Cigar wrote: > >> On Wed, Feb 25, 2015 at 06:10:55PM -0500, Michael Bayer wrote: >> >> >> Julien Cigar wrote: >> >>>> On Thu, Feb 19, 2015 at 11:31:10AM -0500, Michael Bayer wrote: >>>> Jul

Re: [sqlalchemy] Unexpected is_modified result after referencing a relationship

2015-02-27 Thread Michael Bayer
> On Feb 27, 2015, at 4:48 PM, Eric Smith wrote: > > To those more experienced than me, does this behavior make sense? If so, > could you further my education with an explanation? > > If I change an attribute, is_modified returns True (as expected). > If I then reference a relationship, is_m

Re: [sqlalchemy] relationship problem

2015-02-25 Thread Michael Bayer
Julien Cigar wrote: > On Thu, Feb 19, 2015 at 11:31:10AM -0500, Michael Bayer wrote: >> Julien Cigar wrote: >> >>> On Thu, Feb 19, 2015 at 02:45:43PM +0100, Julien Cigar wrote: >>>> Hello, >>>> >>>> I'm using SQLAlchemy 0.

Re: [sqlalchemy] inheritance with multiple foreign keys to the base table

2015-02-24 Thread Michael Bayer
Christopher Singley wrote: > I'm using declared_attr.cascading from sqlalchemy-1.0.0dev to declare a > foreign key on a subclass that also needs another separate foreign key > reference to the parent table. > To let the Mapper know which column to join for the polymorphic inheritance > relat

Re: [sqlalchemy] DetachedInstanceError

2015-02-23 Thread Michael Bayer
> On Feb 22, 2015, at 10:09 PM, Ed Rahn wrote: > > I am occassionally and randomly getting a DetachedInstanceError when I try to > access an object atttribute that is a reference. I will run this several > thousand times and only get it twice. What I don't understand is I use the > same ex

Re: [sqlalchemy] "How can I know which fields cause IntegrityError when inserting into a table with multiple unique fields?"

2015-02-23 Thread Michael Bayer
function that does something similar for other fields that are not the PK. The recipe below is one way to do this. https://bitbucket.org/zzzeek/sqlalchemy/wiki/UsageRecipes/UniqueObject > >> On Thursday, February 19, 2015 at 5:29:56 PM UTC+1, Michael Bayer wrote: &g

Re: [sqlalchemy] relationship problem

2015-02-19 Thread Michael Bayer
Julien Cigar wrote: > On Thu, Feb 19, 2015 at 02:45:43PM +0100, Julien Cigar wrote: >> Hello, >> >> I'm using SQLAlchemy 0.9.8 with PostgreSQL and the reflection feature of >> SQLAlchemy. >> >> I have the following tables (only relevant parts are show): >> https://gist.github.com/silenius/390

Re: [sqlalchemy] "How can I know which fields cause IntegrityError when inserting into a table with multiple unique fields?"

2015-02-19 Thread Michael Bayer
Maurice Schleußinger wrote: > Is there no other way? > > http://stackoverflow.com/questions/27635933/how-can-i-know-which-fiels-cause-integrityerror-when-inserting-into-a-table-with/27884632#27884632 > > Parsing an exception with regex just doesn't feel right… The two other ways are that you

Re: [sqlalchemy] idle in transaction

2015-02-15 Thread Michael Bayer
Ed Rahn wrote: > > On 02/13/2015 11:30 PM, Michael Bayer wrote: >> Ed Rahn wrote: >> >>> I have several programs that are Multi Process and long running, they open >>> up 30 or so connections and do selects periodically. For a select query, >

Re: [sqlalchemy] session.add order

2015-02-15 Thread Michael Bayer
the order in which you put things into session.add() is significant only within the scope of a certain mapped class, that is, the order that you put a bunch of Foo() objects into session.add() will be maintained, however a series of Bar() objects are handled separately. Between different object hi

Re: [sqlalchemy] Problem unpickling metadata for Postgres custom datatype

2015-02-14 Thread Michael Bayer
S P wrote: > I am using SQLAlchemy version 0.9.7. I have ~ 400 tables that I > automatically reflect from the database. I would like to cPickle the > metadata after reflection and store this, then subsequently unpickle the > metadata and use it (for speedup) rather than use reflection agai

Re: [sqlalchemy] Use multiple database for read and write operations

2015-02-14 Thread Michael Bayer
ahmadjaved...@gmail.com wrote: > Hi, > > I am working on a web site using Python Django and SQLAlchemy ORM. I want to > do all read operations in separate database and write operations in separate > database. > So I tried Mike Bayer's solution > (http://techspot.zzzeek.org/2012/01/11/django

Re: [sqlalchemy] idle in transaction

2015-02-13 Thread Michael Bayer
Ed Rahn wrote: > I have several programs that are Multi Process and long running, they open > up 30 or so connections and do selects periodically. For a select query, > the default behaviour is to begin a transaction if not currently in one, > but not commit afterwards. This leaves a large numb

Re: [sqlalchemy] Restricting a delete based on a many-to-many mapping (Using secondary)

2015-02-12 Thread Michael Bayer
Torsten Irländer wrote: > First, thanks for your fast replies Michael! > > Do I understand it correctly that in contrast to plain SQL (Invoking the > delete command in e.g psql), there is no way to make the database side > constraints in the association table applicable in SQLAlchemy if I co

  1   2   3   4   5   6   7   8   9   10   >