Re: [sqlalchemy] pycon 2014

2014-04-01 Thread Michael Bayer
The tutorial that I do is the same one..for the past few years, so the whole thing is up at http://www.sqlalchemy.org/library.html#tutorials . the talk I'm doing, there'll be video of that, sure. On Apr 1, 2014, at 7:33 PM, nathan wrote: > Hi Mike, > > I really wish I could be there and see

[sqlalchemy] pycon 2014

2014-04-01 Thread nathan
Hi Mike, I really wish I could be there and see your presentations. They're usually recorded right? Just checking and hoping it's recorded... and if so, whoever records it does a great job. :) https://us.pycon.org/2014/speaker/profile/455/ Introduction to SQLAlchemy https://us.pycon.org/2014

Re: [sqlalchemy] Re: Mapping lots of similar tables / database design

2014-04-01 Thread Claudio Freire
On Tue, Apr 1, 2014 at 8:21 PM, Jonathan Vanasco wrote: > i didn't catch this before... > > backref_name = "timeseries_%s" % name ## might be better as an the id > of the location > location = relationship('Location', backref=backref(backref_name, > lazy='dynamic')) > > I don't think he c

[sqlalchemy] Re: Mapping lots of similar tables / database design

2014-04-01 Thread Jonathan Vanasco
ah! i didn't catch this before... backref_name = "timeseries_%s" % name ## might be better as an the id of the location location = relationship('Location', backref=backref(backref_name, lazy='dynamic')) I don't think he can do one table. originally i did, but I looked into some

Re: [sqlalchemy] Mapping lots of similar tables / database design

2014-04-01 Thread Claudio Freire
On Tue, Apr 1, 2014 at 8:07 PM, Michael Bayer wrote: > Think about it. You have 2000 individual Python classes all called > TimeSeries, all referring to a different table. This is the question you > have to answer (and which I think is going to wind you up back at one > table): > > 1. which one

Re: [sqlalchemy] Mapping lots of similar tables / database design

2014-04-01 Thread Michael Bayer
On Apr 1, 2014, at 6:56 PM, Peter Stensmyr wrote: > I posted this question on Stack Overflow a few days ago, and got some > response but nothing that really solves my problem. I'm hoping that I can get > some more input here. The initial recommendation was to keep all the data in > two tables

[sqlalchemy] Mapping lots of similar tables / database design

2014-04-01 Thread Peter Stensmyr
I posted this question on Stack Overflow a few days ago, and got some response but nothing that really solves my problem. I'm hoping that I can get some more input here. The initial recommendation was to keep all the data in two tables (one meta and one data table), but this might become unwi

Re: [sqlalchemy] Getting access to postgres copy_from in the middle of a session transaction

2014-04-01 Thread Michael Bayer
On Apr 1, 2014, at 6:07 PM, jjaq...@gmail.com wrote: > So I have an ORM session that I've called session.begin() on to start a > transaction. > > I found from some other posts that I can get access to postgres COPY command > via psycopg2's copy_from method. > > So a simple test case for my co

[sqlalchemy] Getting access to postgres copy_from in the middle of a session transaction

2014-04-01 Thread jjaques
So I have an ORM session that I've called session.begin() on to start a transaction. I found from some other posts that I can get access to postgres COPY command via psycopg2's copy_from method. So a simple test case for my code looks something like this: session.begin() session.execute("CREAT

[sqlalchemy] Re: Session execute mapping

2014-04-01 Thread Jonathan Vanasco
If you have: class MyTable(base): pass You could do session.query( MyTable ).from_statement() * http://docs.sqlalchemy.org/en/rel_0_9/orm/query.html#sqlalchemy.orm.query.Query.from_statement See also: http://docs.sqlalchemy.org/en/rel_0_9/core/tutorial.html#using-text htt

Re: [sqlalchemy] Bitwise Flag Type

2014-04-01 Thread Michael Bayer
On Apr 1, 2014, at 11:28 AM, Alex wrote: > Yeah, its a very frustrating aspect of SQL Server. Anyway, a query that works > is the following: > > SELECT testmodel.id AS testmodel_id, testmodel.flags AS testmodel_flags > FROM testmodel > WHERE (testmodel.flags & 1) > 0 > > I can get sqlalchem

Re: [sqlalchemy] Bitwise Flag Type

2014-04-01 Thread Alex
Yeah, its a very frustrating aspect of SQL Server. Anyway, a query that works is the following: SELECT testmodel.id AS testmodel_id, testmodel.flags AS testmodel_flags FROM testmodel WHERE (testmodel.flags & 1) > 0 I can get sqlalchemy to emit this like so: session.query(TestModel).filter(TestMo

[sqlalchemy] Session execute mapping

2014-04-01 Thread nikola1010
Hi, looked over through documentation and couldn't find any info about mapping from custom sql query to declared object. I have declared object that will describe my table and run custom SELECT query with session.execute(SQL_QUERY). How to map resultproxy (return value) to object. Tnx. --

Re: [sqlalchemy] Defining CheckConstraint if column value is in list of values

2014-04-01 Thread Michael Bayer
On Apr 1, 2014, at 8:44 AM, Michael Howitz wrote: > Hi, > > I want to define a CheckConstraint like this: my_column in ('a', 'b') > In Alembic I can write: op.create_check_constraint('ck_name', 'table_name', > sqlalchemy.sql.column('my_column').in_('a', 'b')) > Using SQLAlchemy I have the pr

Re: [sqlalchemy] Bitwise Flag Type

2014-04-01 Thread Michael Bayer
On Apr 1, 2014, at 6:34 AM, Alex wrote: > Hmm, looks like I spoke too soon. Testing against a SQLite database the > hybrid attribute approach works fine but I'm having some trouble with SQL > Server. Basically, given the structure that Michael laid out, the following > query: > > model =

[sqlalchemy] Defining CheckConstraint if column value is in list of values

2014-04-01 Thread Michael Howitz
Hi, I want to define a CheckConstraint like this: my_column in ('a', 'b') In Alembic I can write: op.create_check_constraint('ck_name', 'table_name', sqlalchemy.sql.column('my_column').in_('a', 'b')) Using SQLAlchemy I have the problem that the constraint must be defined when defining the colu

Re: [sqlalchemy] Re: Bitwise Flag Type

2014-04-01 Thread Alex
Hmm, looks like I spoke too soon. Testing against a SQLite database the hybrid attribute approach works fine but I'm having some trouble with SQL Server. Basically, given the structure that Michael laid out, the following query: model = TestModel( flags=1 ) session.add(model)