Re: [sqlalchemy] Create Table scripts failing randomly - scripts work from sqlite3 driver but not sqlalchemy

2013-09-23 Thread Simon King
A quick google for psycopg multiple statements doesn't turn up anything useful, so I suspect you are going to be out of luck. And unless there are more database drivers than sqlite that support an executescript method, it doesn't seem likely that it'll get added to SQLAlchemy either... For batch

Re: [sqlalchemy] load events with polymorphic_on

2013-09-23 Thread Philip Scott
this is normal, loading for the base class only hits those columns which are defined for that base class - it does not automatically fan out to all columns mapped by all subclasses. to do so, you can specify with_polymorphic: Ahh, thank you very much Michael that does do exactly what I want.

[sqlalchemy] What is declarative_base() exactly?

2013-09-23 Thread Edward Kim
Hi all, I have a really short experience of python so it can be really stupid question. I tried to understanding about declarative_base(). Example below: Base = declarative_base() class Bus(Base): __tablename__ = 'bus' In my understanding, That python code look like function

Re: [sqlalchemy] What is declarative_base() exactly?

2013-09-23 Thread Claudio Freire
On Mon, Sep 23, 2013 at 10:22 AM, Edward Kim onward.ed...@gmail.com wrote: Base = declarative_base() Base class 'sqlalchemy.ext.declarative.api.Base' How this function is return class, not instance? Is it kind of design pattern? I know It is not a big deal for just using SQLAlchemy, but

Re: [sqlalchemy] What is declarative_base() exactly?

2013-09-23 Thread Edward Kim
Oh, I see! It is return class literally. Thanks for your code. On Monday, 23 September 2013 23:28:11 UTC+10, Klauss wrote: On Mon, Sep 23, 2013 at 10:22 AM, Edward Kim onward...@gmail.comjavascript: wrote: Base = declarative_base() Base class 'sqlalchemy.ext.declarative.api.Base'

Re: [sqlalchemy] What is declarative_base() exactly?

2013-09-23 Thread Philip Scott
declarative_base is just a function that returns a class. In python, a class is a first class object just like any other. You can do things like this: class MyClass(object): pass def foo() return MyClass my_class_instance = foo()() In normal use of SQLAlchemy you don't need to think too

Re: [sqlalchemy] another postgresql distinct on question

2013-09-23 Thread Philip Scott
I went though the exact same process of discovery that you did Jonathan :) It does work perfectly but does not get rendered properly when printing out the queries (possibly even when I set echo=True on the connection, if I remember correctly) On Sun, Sep 22, 2013 at 5:44 PM, Jonathan Vanasco

Re: [sqlalchemy] Mutable column_properties

2013-09-23 Thread Philip Scott
Yes, obviously :) But I meant in general for any python type - native postgresql type; I guess there are not that many really I could just handle all the cases I want to use.. On Fri, Sep 20, 2013 at 5:05 PM, Michael Bayer mike...@zzzcomputing.comwrote: On Sep 20, 2013, at 10:35 AM, Philip

Re: [sqlalchemy] load events with polymorphic_on

2013-09-23 Thread Michael Bayer
On Sep 23, 2013, at 8:35 AM, Philip Scott safetyfirstp...@gmail.com wrote: this is normal, loading for the base class only hits those columns which are defined for that base class - it does not automatically fan out to all columns mapped by all subclasses. to do so, you can specify

Re: [sqlalchemy] another postgresql distinct on question

2013-09-23 Thread Michael Bayer
On Sep 23, 2013, at 9:40 AM, Philip Scott safetyfirstp...@gmail.com wrote: I went though the exact same process of discovery that you did Jonathan :) It does work perfectly but does not get rendered properly when printing out the queries (possibly even when I set echo=True on the

Re: [sqlalchemy] Create Table without Metadata and pass it in later?

2013-09-23 Thread Michael Bayer
On Sep 22, 2013, at 11:47 PM, Donald Stufft donald.stu...@gmail.com wrote: Mostly I'm trying to avoid global state like metadata. ironythe purpose of MetaData is to *avoid* global state. If any Table could refer to ForeignKey(someothertable.id), without MetaData it means SQLAlchemy

Re: [sqlalchemy] another postgresql distinct on question

2013-09-23 Thread Jonathan Vanasco
On Monday, September 23, 2013 10:31:16 AM UTC-4, Michael Bayer wrote: it will definitely show the right thing for echo=True, that's what's being sent to the database. yeah, the `echo` in my debug log is what showed me that postgres was getting the right data. i was doing this to audit

Re: [sqlalchemy] another postgresql distinct on question

2013-09-23 Thread Michael Bayer
On Sep 23, 2013, at 10:59 AM, Jonathan Vanasco jonat...@findmeon.com wrote: On Monday, September 23, 2013 10:31:16 AM UTC-4, Michael Bayer wrote: it will definitely show the right thing for echo=True, that's what's being sent to the database. yeah, the `echo` in my debug log is what

Re: [sqlalchemy] Create Table without Metadata and pass it in later?

2013-09-23 Thread Donald Stufft
On Sep 23, 2013, at 11:52 AM, Michael Bayer mike...@zzzcomputing.com wrote: On Sep 23, 2013, at 11:15 AM, Donald Stufft donald.stu...@gmail.com wrote: Well mostly I've isolated other pieces of global state and while metadata itself probably isn't a problem I was hesitant to add it as

Re: [sqlalchemy] Create Table scripts failing randomly - scripts work from sqlite3 driver but not sqlalchemy

2013-09-23 Thread monosij . forums
Sounds good. I will try concating strings for Postgres - see if that works. Seems like it should maybe work from a few posts I read. I tried out the insert on SQLite by zipping the dict keys to values - works great! I tried out the triple-quoting of the strings through SQLAlchemy but that did

Re: [sqlalchemy] Create Table without Metadata and pass it in later?

2013-09-23 Thread Michael Bayer
On Sep 23, 2013, at 11:15 AM, Donald Stufft donald.stu...@gmail.com wrote: Well mostly I've isolated other pieces of global state and while metadata itself probably isn't a problem I was hesitant to add it as a piece of global state since I didn't have anything else like that. I did

[sqlalchemy] Duplicating primary key value into another column upon insert?

2013-09-23 Thread Ken Lareau
Hopefully this will make sense... I have a database which is in need of some normalization of the column naming in various tables. In an effort to minimize disruption (since this is a live database used by many applications), I'm trying to use a two-step approach: 1) Add a new column that will

[sqlalchemy] Query manipulation when using joinedload

2013-09-23 Thread Mick Heywood
Hi, I'm attempting to do some universal filtering using a custom Query class. In this case, I'm trying to filter out all items marked as archived in two related classes. I'm having some trouble adding the required filters to the query at all the right levels. I'm using Flask 0.9, SQLAlchemy