[sqlalchemy] Table has no column named xxxx ??

2008-12-06 Thread Corsair
Hello list, I'm new to sqlalchemy and database programming. I have defined a declarative class import sqlalchemy as SQL import sqlalchemy.ext.declarative as Declare import sqlalchemy.orm as ORM import datetime Base = Declare.declarative_base() class CUniversity(Base): __tablename__ =

[sqlalchemy] Column('last_updated', onupdate=func.current_timestamp())

2008-12-06 Thread jo
Hi all, I created a table with the following column: Column('last_updated', DateTime, PassiveDefault(func.current_timestamp ()), onupdate=func.current_timestamp()) Maybe I don't understand how onupdate works. I would like to have this column to be changed every time the row is updated, but it

[sqlalchemy] Re: MySQL, unions and ordering

2008-12-06 Thread Michael Bayer
you'd say, s.alias().select() it makes subqueries which MySQL probably doesn't require. On Dec 5, 2008, at 10:35 PM, Bo Shi wrote: Thanks; the monkeypatch approach works nicely. Using the alias() method will raise AttributeError: 'Alias' object has no attribute '_order_by_clause'

[sqlalchemy] Re: Column('last_updated', onupdate=func.current_timestamp())

2008-12-06 Thread Michael Bayer
that is the correct syntax. It will take effect any time an update() construct is used or when the ORM updates a row. Because onupdate is not a DDL-side construct, it will not take effect if you use a plain text UPDATE statement or if the update is otherwise not emitted by the

[sqlalchemy] Re: Column('last_updated', onupdate=func.current_timestamp())

2008-12-06 Thread Empty
Column('last_updated', DateTime, PassiveDefault(func.current_timestamp ()), onupdate=func.current_timestamp()) Maybe I don't understand how onupdate works. I would like to have this column to be changed every time the row is updated, but it doesn't work. I just use something like:

[sqlalchemy] circular reference

2008-12-06 Thread jose
Hi all, I have two tables in my schema with circular references and I don't know hot to create them. tbl['anagrafica']=Table('anagrafica',database.metadata, Column('id', Integer, Sequence('anagrafica_id_seq'), primary_key=True, nullable=False), Column('nome', Unicode(200),

[sqlalchemy] create index with a condition

2008-12-06 Thread jose
Hi all, I would like to create an index with a condition, like this: CREATE UNIQUE INDEX univocita_codice_aziendale on azienda (lower(codice_aziendale), stato_record) WHERE stato_record = 'A' Is there a way to do that, using the Index() command? j

[sqlalchemy] Re: utf hex instead of utf-8 return

2008-12-06 Thread n00b
thanks for the quick reply. i kept trying with it and no have reached the utter state of confusion. the specification of Unicode versus String in the table def's coupled with actual str representation has my totally confused. here's a quick script, have a look at the mysql table itself to see

[sqlalchemy] Re: SQLAlchemy Sphinx Documentation Preview

2008-12-06 Thread Eric Ongerth
You're right about CSS selectors; the simple fix for this without re- generating any source, is just to instruct the browser to not double up on the indentation when it sees a ul nested in a blockquote. Hey wait, the problem is already fixed. Looks great today. The lists too; thanks for the

[sqlalchemy] Re: create index with a condition

2008-12-06 Thread Michael Bayer
Postgres supports this using the postgres_where keyword argument sent to Index(). Otherwise use DDL(). http://www.sqlalchemy.org/docs/05/reference/dialects/postgres.html?highlight=postgres_where#indexes

[sqlalchemy] Re: circular reference

2008-12-06 Thread Michael Bayer
specify use_alter=True to one or both ForeignKey constructs. On Dec 6, 2008, at 12:37 PM, jose wrote: Hi all, I have two tables in my schema with circular references and I don't know hot to create them. tbl['anagrafica']=Table('anagrafica',database.metadata, Column('id',

[sqlalchemy] Re: Column('last_updated', onupdate=func.current_timestamp())

2008-12-06 Thread jose
Yes, Michael, I see how it works now. Thank you j Michael Bayer wrote: that is the correct syntax. It will take effect any time an update() construct is used or when the ORM updates a row. Because onupdate is not a DDL-side construct, it will not take effect if you use a plain text

[sqlalchemy] Re: circular reference

2008-12-06 Thread jose
the use_alter=True raises this error: ForeignKeyConstraint(['id_operatore'],['operatore.id'],use_alter=True), File /usr/lib/python2.4/site-packages/sqlalchemy/schema.py, line 701, in __init__ raise exceptions.ArgumentError(Alterable ForeignKey/ForeignKeyConstraint requires a name)

[sqlalchemy] Re: create index with a condition

2008-12-06 Thread jose
Are these features available on ver. 0.3? j Michael Bayer wrote: Postgres supports this using the postgres_where keyword argument sent to Index(). Otherwise use DDL(). http://www.sqlalchemy.org/docs/05/reference/dialects/postgres.html?highlight=postgres_where#indexes

[sqlalchemy] Re: circular reference

2008-12-06 Thread jose
I gave it a name but now... raise FlushError(Circular dependency detected + repr(edges) + repr(queue)) sqlalchemy.exceptions.FlushError: Circular dependency detected sqlalchemy.topological._EdgeCollection object at 0xb73f356c[] jose wrote: the use_alter=True raises this error:

[sqlalchemy] How can I reuse the string syntax in my own code?

2008-12-06 Thread Jorge Vargas
Hi, I have been working on a little project to transform excel docs (actually them saved as csv files) into SQLAlchemy objects. Of course this is tailored for my own database which I need to import but I have been splitting it into api more and more and eventually plan to release it as some

[sqlalchemy] Re: circular reference

2008-12-06 Thread Michael Bayer
that's an ORM problem.you might want to look into the post_update flag if you need to flush two mutually dependent rows. See the relation() docs for details. On Dec 6, 2008, at 3:41 PM, jose wrote: I gave it a name but now... raise FlushError(Circular dependency detected +

[sqlalchemy] Re: create index with a condition

2008-12-06 Thread Michael Bayer
they are not. you can of course issue any DDL you'd like using engine.execute(somestring). On Dec 6, 2008, at 3:39 PM, jose wrote: Are these features available on ver. 0.3? j Michael Bayer wrote: Postgres supports this using the postgres_where keyword argument sent to Index().

[sqlalchemy] Re: How can I reuse the string syntax in my own code?

2008-12-06 Thread Michael Bayer
On Dec 6, 2008, at 4:16 PM, Jorge Vargas wrote: So in order to make code a lot more readable I was thinking I could use the syntax SA uses for filter and such so I can write the _excel_to_field as _excel_to_field = { 'First Name' : 'Contact.first_name', 'Last Name' :

[sqlalchemy] Extending sqlalchemy.schema.Column and metaprogramming traps

2008-12-06 Thread Angri
Hello. I had a problem described in subject. Here is the testcase: import sqlalchemy engine = sqlalchemy.create_engine('sqlite:///:memory:') metadata = sqlalchemy.MetaData(engine) class ForeignKey(sqlalchemy.Column): def __init__(self, name, foreign_column, *args, **kwargs): fk =

[sqlalchemy] Re: Extending sqlalchemy.schema.Column and metaprogramming traps

2008-12-06 Thread Michael Bayer
On Dec 6, 2008, at 4:27 PM, Angri wrote: 1. What about another side-effects depending on clsname? Is it actually safe to extend sqlalchemy.schema.Column, or it may have unpredictable behavior similar to that i've encountered? The Column object is one of the most key classes in all of

[sqlalchemy] Re: MySQL, unions and ordering

2008-12-06 Thread Bo Shi
Right; my bad - I misread the instructions. On Sat, Dec 6, 2008 at 9:41 AM, Michael Bayer [EMAIL PROTECTED] wrote: you'd say, s.alias().select() it makes subqueries which MySQL probably doesn't require. On Dec 5, 2008, at 10:35 PM, Bo Shi wrote: Thanks; the monkeypatch approach works

[sqlalchemy] Re: objects created using sqlalchemy

2008-12-06 Thread Faheem Mitha
On Fri, 5 Dec 2008, Faheem Mitha wrote: Hi, I'm using sqla with the following schema (see below). I'm creating a cell object implicitly, using the function make_cell and the association proxy pattern. def make_cell(patient_obj, snp_obj, snpval): patient_obj.snps[snp_obj] = snpval

[sqlalchemy] Re: I can replace an object with another in python, by changing the object dict to the other object dict. How does it settle with sqlalchemy? Does it works when another mapped object

2008-12-06 Thread kobi...@gmail.com
I have talked to my customers, and they agreed that your solution is great. To match their demands, I've changed two things: 1. If the object exists in the db during construction than it's returned, else the object returned is a new object (that isn't returned). 2. All the attributes that