elixir

Pylons with Elixir

I would like to use Pylons with Elixir, however, I am not sure what is the best way to get about doing this. There are several blog posts (cleverdevil, beachcoder, adam hoscilo) and even an entire new framework about how to go about doing this; however, I am not certain about the differences between them. Which one is the best to use? Am...

SQLAlchemy/Elixir validation rules?

I just found out how to validate my database input before saving it, but I'm kinda bummed to find there are no premade rules (like validate email, length, etc) that are found in some web based frameworks. Are there any validation libraries laying around anywhere or somewhere that some premade validation lists are hiding that I haven't fo...

Elixir Event Handler

I want to use the @after_insert decorator of Elixir, but i can't access the Session within the model. Since i have autocommit set to False, i can't commit any changes in the event handler. Is there any best practice how to deal with that? The Code I used to build model, database connection etc. are mostly taken off the documentations. ...

Elixir reflection

I define some Entities wich works fine; for meta programming issues, i now need to reflect the field properties defined in the model. For example: class Foo(Entity): bar = OneToMany('Bar') baz = ManyToMany('Baz') here i need the information which type of relation is set: "ManyToMany", "OneToMany" or even a plain "Field", ...

Elixir (SqlAlchemy): relations between 3 tables with composite primary keys

I've 3 tables: A Company table with (company_id) primary key A Page table with (company_id, url) primary key & a foreign key back to Company An Attr table with (company_id, attr_key) primary key & a foreign key back to Company. My question is how to construct the ManyToOne relation from Attr back to Page using the existing columns in...

Elixir Entity with a list of tuples in it. ex. Cooking Recipe with list of (ingrediant, quantity) tuple

Hi I'm trying to build an elixir model in which I have a class with a list(of variable size) of tuples. One example would be a recipe while I can do something like this: class Recipe(Entity): ingrediants = OneToMany('IngrediantList') cooking_time = Field(Integer) ... class IngrediantList(Entity): ingrediant = ManyToO...

Issues with scoped_session in sqlalchemy - how does it work?

I'm not really sure how scoped_session works, other than it seems to be a wrapper that hides several real sessions, keeping them separate for different requests. Does it do this with thread locals? Anyway the trouble is as follows: S = elixir.session # = scoped_session(...) f = Foo(bar=1) S.add(f) # ERROR, f is already attached to sess...

Python SQLAlchemy/Elixer Question

I am trying to define a SQLAlchemy/Elixer model that can describe the following relationship. I have an SSP table, which has multiple Foreign Keys to the POC table. I've defined the ManyToOne relationships correctly within the SSP object (allowing me to SSP.get(1).action.first_name correctly). What I would also like to add is the other s...

Using multiple databases with Elixir

I would like to provide database for my program that uses elixir for ORM. Right now the database file (I am using SQLite) must be hardcoded in metadata, but I would like to be able to pass this in argv. Is there any way to do this nice? The only thing I thought of is to: from sys import argv metadata.bind = argv[1] Can I set this in...

Nested transactions with SQLAlchemy and sqlite

I'm writing an application in python using sqlalchemy (and Elixir) with sqlite as the database backend. I start a new transaction using the code session.begin_transaction(), but when I call session.rollback() I get the following error: sqlalchemy.exceptions.OperationalError: (OperationalError) no such savepoint: sa_savepoint_1 u'ROLLBAC...

Elixir not creating my tables with default values

class MyObject(Entity): name = Field(Unicode(256), default=u'default name', nullable=False) using_options(shortnames=True) using_mapper_options(save_on_init=False) def __init__(self): self.name = None I am using MySQL in this case, but have also checked against SQLite and I get the same result. It respects nul...

Execute sql query with Elixir

I'm using Elixir in a project that connects to a postgres database. I want to run the following query on the database I'm connected to, but I'm not sure how to do it as I'm rather new to Elixir and SQLAlchemy. Anyone know how? VACUUM FULL ANALYZE table Update The error is: "UnboundExecutionError: Could not locate a bind configured on ...

Selecting distinct column values in SQLAlchemy/Elixir

In a little script I'm writing using SQLAlchemy and Elixir, I need to get all the distinct values for a particular column. In ordinary SQL it'd be a simple matter of SELECT DISTINCT `column` FROM `table`; and I know I could just run that query "manually," but I'd rather stick to the SQLAlchemy declarative syntax (and/or Elixir) if I c...

HTTP Base SQLAlchemy database

Hi all. I have a little problem, I want to use SQLAlchemy (Elixr to be exact) to do some task on a RDBMS MySql on a web server I have in hosting. My Hosting provider does not allowe me to connect to MySql directly, just by php scripts... I was think to use a simple php script to tunnel the queies done by SQLAlchemy. There is some way to...

Elixir create_all() not creating database and tables

Hey, I'm using Elixir 0.7.1 , Sqlalchemy 0.6beta1 , MySQLdb 1.2.2. My Model file 'model.py' looks like this: from elixir import * from datetime import datetime class Author: first_name = Field(Unicode(64)) last_name = Field(Unicode(64)) class Article: title = Field(Unicode(64)) class Category: name = Field(Unicode(64)) setu...

How do I create self-relationships in polymorphic inheritance in Elixir and Pylons?

I am new to programming and am following the example in the Pylons documentation on creating a Wiki. The database I want to link to the wiki was created with Elixir so I rewrote the Wiki database schema and have continued from there. In the wiki there is a requirement for a Navigation table which is inherited by Pages and Sections. A s...

In Elixir or SQLAlchemy, is there a way to also store a comment for a/each field in my entities?

Our project is basically a web interface to several systems of record. We have many tables mapped, and the names of each column aren't as well named and intuitive as we'd like... The users would like to know what data fields are available (i.e. what's been mapped from the database). But, it's pointless to just give them column names like...

Multiple foreign keys to same table using Elixir

Hello, I am new to ORMs in general. I have a table (lets call it Entity) with columns -- ID expression type ( can be 'long_word', 'short_word' or 'sentence' ) Often, the first two types occur in a 'sentence', so, I want to maintain another table which maps 'Sentences' to 'long_word' or 'short_word' using the 'ID' field. All i need...

Update an sqlite database schema with sqlalchemy and elixir

I've created a python application which uses elixir/sqlalchemy to store data. The second release of the software requires any files created in the previous version to be updated in order to add/delete tables and columns. My question is: how can I achieve this? I'm aware of sqlalchemy-migrate, but I must say I find it confusing. It doesn...

How to create a non-persistent Elixir/SQLAlchemy object?

Hi, because of legacy data which is not available in the database but some external files, I want to create a SQLAlchemy object which contains data read from the external files, but isn't written to the database if I execute session.flush() My code looks like this: try: return session.query(Phone).populate_existing().filter(Phone.ma...