Re: [sqlalchemy] How to connect to an already existing database in SqlAlchemy?

2014-07-04 Thread Michael Weylandt
Set app.config[SQLALCHEMY_DATABASE_URI] to point to your database. Normally won't create tables unless you call flask.ext.sqlalchemy.SQLAlchemy.creae_all explicitly. On Jun 27, 2014, at 1:47 PM, Aarushi ign ign.aaru...@gmail.com wrote: I am using Flask-SqlAlchemy. It does allows you to

Re: [sqlalchemy] ORM Different SELECT/INSERT Tables

2014-06-18 Thread Michael Weylandt
Bumping this, is there a way to do a replacement with_polymorphic instead of an addition? Michael On Tuesday, April 8, 2014 3:59:34 PM UTC-4, Michael Weylandt wrote: On Monday, April 7, 2014 5:11:48 PM UTC-4, Michael Bayer wrote: On Apr 7, 2014, at 2:46 PM, Michael Weylandt michael

Re: [sqlalchemy] ORM Different SELECT/INSERT Tables

2014-06-18 Thread Michael Weylandt
if a polymorphic_on isn't set, as with_polymorphic wasn't intended to be used for this use case (but there's nothing else that's very great for this case that isn't explicit at the Query level). On 6/18/14, 6:46 PM, Michael Weylandt wrote: Bumping this, is there a way to do a replacement

[sqlalchemy] Re: How to have SQL IF in sqlalchemy

2014-06-18 Thread Michael Weylandt
Look at sqlalchemy.sql.func: http://docs.sqlalchemy.org/en/rel_0_9/core/functions.html On Wednesday, June 18, 2014 8:31:04 PM UTC-4, Vineet Goel wrote: Hi, I am trying to convert the following SQL to SQLAlchemy: SELECT teams.department, teams.team, IF(employee_managers.team_id IS

Re: [sqlalchemy] Emission of Different DDL for Null and Not Null Columns

2014-06-09 Thread Michael Weylandt
On Saturday, June 7, 2014 12:59:42 PM UTC-4, Michael Bayer wrote: If this is more at the user land level, I’d do a type like this: class TinyintBoolean(TypeDecorator): impl = TINYINT def process_bind_param(self, value, dialect): return None if value is None else

[sqlalchemy] Emission of Different DDL for Null and Not Null Columns

2014-06-06 Thread Michael Weylandt
I'm working with a database (Sybase ASE) which supports a non-null BIT type. For Column(Boolean, nullable=False), SQLA's use of BIT is ideal, but I need to have Column(Boolean, nullable=True) produce a TINYINT + Check constraint. The DDL compiler only provides the type (not the full column)

Re: [sqlalchemy] ORM Different SELECT/INSERT Tables

2014-04-08 Thread Michael Weylandt
On Monday, April 7, 2014 5:11:48 PM UTC-4, Michael Bayer wrote: On Apr 7, 2014, at 2:46 PM, Michael Weylandt michael@gmail.comjavascript: wrote: Since the logic creating the view is a little hairy, I'd like to avoid replicating it in Python and just have SQLAlchemy redirect all

[sqlalchemy] ORM Different SELECT/INSERT Tables

2014-04-07 Thread Michael Weylandt
Is it possible to have SQLAlchemy use different tables for SELECT and INSERT statements? I'm using the Declarative/ORM setup with Flask-SQLAlchemy and I am faced with a very large table and a view which shows a subset of that table. Since the logic creating the view is a little hairy, I'd

[sqlalchemy] Getting DDL from event listeners by reflection

2014-04-03 Thread Michael Weylandt
I've created an application using the declarative extension to the ORM and I'm trying to auto-generate parts of my documentation. Using the stdlib's inspect.getsource() I can recover the class definitions and using sqlalchemy.schema.CreateTable() I can get most of my DB schema. My application

Re: [sqlalchemy] group max, outerjoin, and subquery

2014-03-12 Thread Michael Weylandt
, at 8:23 PM, Michael Weylandt michael@gmail.comjavascript: wrote: Sorry for the barrage, Mike. I didn't check my code worked before I posted (shame on me). I'm looking for: CREATE TABLE #B_temp AS (SELECT * FROM B WHERE id IN (SELECT id FROM B JOIN (SELECT max(number) mn FROM B GROUP

Re: [sqlalchemy] group max, outerjoin, and subquery

2014-03-12 Thread Michael Weylandt
it by hand it works though, so I'll have to look elsewhere to resolve that. I do note that only A is returned as an object. Is there any way to get B and C wrapped up nicely by the ORM as well? Michael On Wednesday, March 12, 2014 12:02:10 PM UTC-4, Michael Weylandt wrote: Hi Mike, Thanks

Re: [sqlalchemy] group max, outerjoin, and subquery

2014-03-11 Thread Michael Weylandt
:32 PM UTC-4, Michael Bayer wrote: can you express the exact query you want in SQL? I can translate to that easily if you have it. Otherwise if you’re looking to figure out what the SQL would be I’d have to find time to look more closely. On Mar 11, 2014, at 7:29 PM, Michael Weylandt

[sqlalchemy] group max, outerjoin, and subquery

2014-03-11 Thread Michael Weylandt
Database wizards, I've got a situation where I have one table with multiple one-to-many mappings (i.e., it is the one in a one-to-many with more than one other table). For each row of the one, I want to group each of the manys by some column and do an outer join between the one and the

Re: [sqlalchemy] group max, outerjoin, and subquery

2014-03-11 Thread Michael Weylandt
); SELECT A.*, #B_temp.*, #C_temp.* FROM A LEFT OUTER JOIN #B_temp ON A.id = #B_temp.A_id LEFT OUTER JOIN #C_temp on A.id = #C_temp.A_id; Michael On Tuesday, March 11, 2014 7:57:36 PM UTC-4, Michael Weylandt wrote: I think I'm looking for something like this: CREATE TABLE #B_temp(id INTEGER, A_id

Re: [sqlalchemy] group max, outerjoin, and subquery

2014-03-11 Thread Michael Weylandt
11, 2014, at 7:29 PM, Michael Weylandt michael@gmail.comjavascript: wrote: Database wizards, I've got a situation where I have one table with multiple one-to-many mappings (i.e., it is the one in a one-to-many with more than one other table). For each row of the one, I want