[sqlalchemy] Re: Using Sqlalchmy with pyodbc driver to access a MS SQL Server

2012-11-09 Thread Andrea Cappelli
Hi, I solved the problem putting [FreeTDS] Description = TDS driver (Sybase/MS SQL) Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so in /etc/odbcinst.ini and using the following uri mssql+pyodbc://user:pass@host:1433/dbname?driver=FreeTDS Hope this helps Andrea Il giorno venerdì 9

[sqlalchemy] relationship problem

2012-11-09 Thread Werner
Hi, I don't understand why on one record I don't get the authuser relation. My definition is: class Cellar(DeclarativeBase, mix.StandardColumnMixin): __tablename__ = u'cellar' name = sa.Column(sa.Unicode(length=50), nullable=False) fk_authuser_id = sautils.reference_col('authuser')

Re: [sqlalchemy] [Q] Move elements in one-to-many relationship to a new owner

2012-11-09 Thread Ladislav Lenart
Hello. I managed to solve my problem. I use session.execute(...) instead of session.delete(), because the second form deletes more things than it should. The working code is: # Move some client products from a duplicate to the original. # Remove duplicate clients afterwards (in cascade).

[sqlalchemy] Named tuples in SQLAlchemy

2012-11-09 Thread Christoph Zwerschke
Query results in SQLAlchemy are returned as named tuples, but SQLAlchemy uses its own flavor of named tuples which is not fully compatible with collections.namedtuple in the standard lib. For instance, _fields is called _labels in SQLAlchemy, and the method _asdict() which could be helpful to

[sqlalchemy] Problems filtering on primary_join with ORM relationship

2012-11-09 Thread Benjamin Sims
Hi, We have a relationship that looks something like this: User 1 - * Posts Posts can have various states, let's say 'DRAFT', 'LIVE', 'DELETED'. Sometimes, we want to get all of the posts in existence for a user by doing: user.all_posts Sometimes, we just want to get posts that are not

Re: [sqlalchemy] Best Practice for model discovery?

2012-11-09 Thread Chris Withers
I tend to use a venusian scan (a pyramid config scan does the same thing) which spiders your package and makes sure everything is imported Check out my mortar_rdb package for some more fun and games in this area, although I need to give it a re-write to use alembic instead of the terrible

Re: [sqlalchemy] [Q] Move elements in one-to-many relationship to a new owner

2012-11-09 Thread Michael Bayer
there's no mapping or code example provided here, which makes a condition like this extremely difficult to diagnose, however I've prepared a test script that takes its best guess as to configuration, that is, a client_products collection with a client backref, and a cascade of all,

Re: [sqlalchemy] (SQLite) Outside auto-locking based on SQLAlchemy Events

2012-11-09 Thread Michael Bayer
On Nov 8, 2012, at 5:01 PM, Torsten Landschoff wrote: My first tests with the SQLAlchemy core where promising, but when using the ORM I get a bunch of deadlocks where it seems like the session opens two connections A and B where A locks B out. The Session never does this, assuming just one

Re: [sqlalchemy] relationship problem

2012-11-09 Thread Michael Bayer
On Nov 9, 2012, at 3:45 AM, Werner wrote: Hi, I don't understand why on one record I don't get the authuser relation. My definition is: class Cellar(DeclarativeBase, mix.StandardColumnMixin): __tablename__ = u'cellar' name = sa.Column(sa.Unicode(length=50), nullable=False)

Re: [sqlalchemy] Named tuples in SQLAlchemy

2012-11-09 Thread Michael Bayer
NamedTuple is a tough one - because with our result sets we need to create a new NamedTuple for every call to execute(), meaning it has to be performant not just on creating new instances of the tuple, but on creating new tuple types as well. If you look at the source to NamedTuple, it is

Re: [sqlalchemy] Problems filtering on primary_join with ORM relationship

2012-11-09 Thread Michael Bayer
On Nov 9, 2012, at 10:55 AM, Benjamin Sims wrote: Hi, We have a relationship that looks something like this: User 1 - * Posts Posts can have various states, let's say 'DRAFT', 'LIVE', 'DELETED'. Sometimes, we want to get all of the posts in existence for a user by doing: