sqlalchemy

Define a varbinary(max) column using sqlalchemy on MS SQL Server

Hi, I'm querying an SQL Server database using SQLAlchemy and need to cast a column to varbinary(max). The thing I am struggling with is the "max" part. I can get the cast to work for any actual number (say varbinary(20)), but I cannot find how to get it to work for the "max" size of the varbinary column. Any pointers? Links? Solutions?...

Clear sqlalchemy reflection cache

Hi all, I'm using sqlalchemy's reflection tools to get a Table object. I do this because these tables are dynamic and tables/columns can change. Here's the code I'm using: def getTableByReflection(self, tableName, metadata, engine): return Table(tableName, metadata, autoload = True, autoload_with = engine) The problem is that wh...

SQLAlchemy: Inserting the results of a query into another table

So I have some results which I've got from the install table, like so: install = metadata.tables['install'] results = session.query(install) #<sqlalchemy.orm.query.Query object> I'd like to insert these same results into the install_archive table. I'm not entirely sure how to do this, because I don't want to duplicate the schema b...

Defining a part of a column as a unique field in sqlalchemy

In sqlalchemy 0.5 i have a table defined like this one: orders = Table('orders', metadata, Column('id', Integer, primary_key=True), Column('responsable', String(255)), Column('customer', String(255)), Column('progressive', Integer), Column('date', Date), Column('exported', Boolean()), ) Is it possible t...

SQLAlchemy and Elixir?

I have been using django ORM, it's nice and very easy, but this time I'm doing a desktop app and I found SQLAlchemy, but I'm not sure to use it with Elixir. What do you think? is it really useful? ...

SQLAlchemy returns empty, though the generated SQL returns full

I have this code: db.query(sets, stores).select_from(orm.join(sets, stores,\ sets.store_scheme_id == stores.store_id)).filter(sets.id == id).one() And I have the SQL debugging level at DEBUG, so it prints out the generated SQL query before it returns. The generated SQL works fine in phpmyadmin. SQLAlchemy, however, DOESN'T work fine a...

EDI X12 Templates in Python (Most likely django or jinja) (w/ sqlalchemy)

My Case: I'm working on a system that will need to create various X12 files for health care (insurance) transactions and inquiries (Specifically 270 Eligibility and 837 Claim). I know there are good tools out there (pyx12 specifically) for converting between XML and X12, and actually I've gone as far as importing some components from ...

Pylons + SQLAlchemy problem: The transaction is inactive due to a rollback in a subtransaction

I have a problem with Pylons + SQLAlchemy. When something goes wrong (in my case it is integrity error, due to a race condition) and the database error is raised, all following requestы result in the error being raised: InvalidRequestError: The transaction is inactive due to a rollback in a subtransaction. Issue rollback() to cancel t...

SQLAlchemy recursive many-to-many relation

Heya! I've a case where I'm using one table to store user and group related datas. This column is called profile. So, basically this table is many-to-many table for the cases where one user is belonging in to many groups or there are many users in one group. I'm a bit confused how it should be described... Here's a simplified presenta...

Quick & dirt CRUD interface to SQLAlchemy?

I'm researching software components to use in a future development of a business logic web application. It's gonna be written in Python and we are targeting SQLAlchemy as ORM. The app will be used by other software apps via a REST-like interface over http, possibly using web.py for that part. For debugging, maintenance, etc we need to d...

one field with diferent datatypes [SQLAlchemy]

i have a value that can be integer, float or string, and i create diferent columns: #declarative class MyClass(Base): #id and other Columns _value_str = Column(String(100)) _value_int = Column(Integer) _value_float = Column(Float) def __init__(self,...,value): self._value_str = value if isinstance(value,(...

SQLAlchemy many-to-many relationship on declarative tables

I have the following tables defined declaratively (very simplified version): class Profile(Base): __tablename__ = 'profile' id = Column(Integer, primary_key = True) name = Column(String(65), nullable = False) def __init__(self, name): self.name = name class Question(Base): __tablename_...

sqlalchemy's create_all doesn't create sequences automatically

I am using SQLAlchemy 0.4.8 with Postgres in order to manage my datastore. Until now, it's been fairly easy to automatically deploy my database: I was using metadata.create_all(bind=engine) and everything worked just fine. But now I am trying to create a sequence that it's not being used by any table, so create_all() doesn't create it, e...

how to use session without having to pass it [SqlAlchemy]

I want to check diferent values in the DB and create a new value, so i need to query and i don't know if i have to create a session in my SQLAlchemy class or how do i have to do it? using session like a global?, i didn't find in documentation. Somethin like this: class MyClass(Base): __tablename__ = 'my_class' __table_args__ =...

Pylons TextMate Bundle

I am looking for a TextMate Bundle for Pylons development. Does anyone know of an existing bundle for Mako and/or SQLAlchemy. I found these two existing articles but the links are no longer valid If someone knows of a currently active link please let me know Thanks ...

How to select rows from an SQL model for a QListView connected to it

I am trying the following in PyQt4, using SQLAlchemy as the backend for a model for a QListView. My first version looked like this: class Model(QAbstractListModel): def __init__(self, parent=None, *args): super(Model, self).__init__(parent, *args) def data(self, index, role): if not index.isValid(): ...

sqlalchemy filter using in_

Is there a more efficient way to do the following? I am more interested in knowing if there is a way to set "mylist" to match anything if day is equal to 'all' because in other scenarios, "mylist" can contain a lot more elements. if day == 'all': mylist = ['monday','tuesday','wednesday','thursday','friday','saturday','sunday'] els...

Why are session methods unbound in sqlalchemy using sqlite?

Code replicating the error: from sqlalchemy import create_engine, Table, Column, Integer from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker Base = declarative_base() class Message(Base): __tablename__ = 'messages' id = Column(Integer, primary_key=True) message = Column(Integer)...

Cascading a delete to a many-to-many association table?

Hi, I have a problem with cascading a delete. I have two tables, and they are mapped many-to-many: class File(object): pass file_table = Table('file', metadata, Column('id', Integer, primary_key=True, autoincrement=True), Column('filename', String(255)), } class FileHost(object): pass file_host = Table('host', ...

how to delete an attribute when a flush or commit has finished in a MapperExtension [sqlalchemy]

I was trying to get the last value "before_insert" a new item but i didn't find out, so i change of strategy and i saved the last value of this method, but the problem is that when i do other commits my old MapperExtension attribute (self.last_value) get the last value and i dislike it, even when I close and open a new Session (discovere...