[sqlalchemy] Off Topic: Declarative-style for XML?

2009-12-18 Thread AF
Hello, I've become quite used to SQLAlchemy's Declarative style notation for defining data to be stored in SQL. Does anyone know of library that will do something similar for simple XML? Basically I need objects (and attributed collections of objects) that are effectively records for groups of s

[sqlalchemy] [TYPO FIX] UNION with SQLAlchemy: Some questions

2009-11-05 Thread AF
So I have several questions: 1) Is the the raw SQL I am using sane? 2) How can I use SQLAlchemy to simply things? 3) How would I add tables events_c? events_d? 4) Since the events_x tables are already defined with declarative_base, is there a reasonable way to make an SQLAlchemy "Events"

[sqlalchemy] UNION with SQLAlchemy: Some questions

2009-11-05 Thread AF
quot;Events" object that knows where to retrieve and insert event records based on the "event_type" field? Thank you, AF --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. T

[sqlalchemy] Re: Multi table select?

2009-11-04 Thread AF
On Oct 27, 8:03 am, Mike Conley wrote: > On Mon, Oct 26, 2009 at 10:09 PM, Bobby Impollonia wrote: > > Let's say you have 2 mapped classes > class Stuff1(Base): >      --- etc. > class Stuff2(Base) >      --- etc. > > You can do something like this > > q1 = session.query(Stuff1.co

[sqlalchemy] Re: Multi table select?

2009-10-26 Thread AF
On Oct 26, 8:48 pm, AF wrote: > Hello, > > I don't know if this is even possible is SQL, so please bear with > me :) > > There are a couple a tables (say, a & b) that are used as "logs" for > two different processes.   They both have the same simp

[sqlalchemy] Multi table select?

2009-10-26 Thread AF
Hello, I don't know if this is even possible is SQL, so please bear with me :) There are a couple a tables (say, a & b) that are used as "logs" for two different processes. They both have the same simple structure. (id, time_stamp, user_id, message) I would like to create a query that mer

[sqlalchemy] Report generation?

2009-10-26 Thread AF
Hello, For instance if I have data tables for users, orders, and order_line_items how would I generate a report that lists: 1) users, 2) and for each user, his/her orders, 3) and for each order, all the order_line_items I guess I could do it in a loop in python, but I wonder of there is a bette

[sqlalchemy] DateTime: Example code?

2009-09-07 Thread AF
Hello, This may be a simple questions What is the correct way to: 1) Define a "time stamp" column that takes on the current "UTC" time by default. 2) Query for records that more than 15 minutes old? For #1, is it some thing like this? "Column('time_stamp', DateTime, default = datetime.u

[sqlalchemy] Testing SQLAlchemy based app? (Tutorial?)

2009-08-13 Thread AF
Hello, I'm writing a basic SQLAlchemy application, and have started to explore the concept of unit testing in general and specifically with nose. Since I am new to both SQLAlchey and nose, I do not know where to start. Right now the app is at the point where: 1) The tables are defined with dec

[sqlalchemy] VIEW alternative in SQLAlchemy

2009-08-07 Thread AF
Hello, I have a table of records in the database that I want to run read queries against, but I do want to include all of them in the search. (There are a couple of filtering parameters to exclude records from the searched pool, including an aptly named "is_active" flag.) Traditionally, I would

[sqlalchemy] Materialized Path for SQLAlchemy & Declarative Base

2009-08-06 Thread AF
Hello all, Has anyone here used the "sqlamp: Materialized Path for SQLAlchemy" library? I am wondering: 1) Does it seem to work well? 2) Did you use it with Declarative Base, and if so, how did you configure it? Thank you, :) --~--~-~--~~~---~--~~ You received

[sqlalchemy] Declarative Base: remote_side & single_parent

2009-08-06 Thread AF
Hello, What is the correct way to use remote_side & single_parent relation parameters under Declarative Base? I'm trying to create an Adjacency List Relationship as suggested in the docs, but I am not sure how to do this with Declarative Base. I tried: children = relation("Node", backref=backr

[sqlalchemy] Suggestions for db connect string configuration?

2009-08-05 Thread AF
Hello, Where do you folks recommend storing the database connection string in my application. Clearly not in the same file with my declaratively defined model objects. And more generally, how do you recommend laying out an SQLAlchemy based application? (In what files to define the engine, sess

[sqlalchemy] Relation w/ declarative

2009-08-05 Thread AF
Am starting to experiment with declarative base. In the code block at: http://www.sqlalchemy.org/docs/05/ormtutorial.html#building-a-relation Why does __init__() not contain any mention of the foreign key "user_id"? In what way is the Address object expected to be instantiated such that it rec

[sqlalchemy] Hierarchical data: Get all (sub-) children? Parents?

2009-07-27 Thread AF
Hello, Given hierarchical data similar to: http://www.sqlalchemy.org/docs/05/mappers.html?#adjacency-list-relationships With out resorting to brute force recursive queries in my objects: 1) Is there any way to retrieve all a node's children / sub-children? 2) Is there a way to retrieve the lis

[sqlalchemy] CircularDependencyError? (Wrong approach?)

2009-07-17 Thread AF
Hello, I have tables: Users & Departments. (SQlite) Each "User" is assigned to one Department. (User.dept_id = Department.id ) Now, I want to make once User in each Dept the "default user". As in: Department.default_user_id = User.id i.,e. Column('default_user_id', ForeignKey('users.id'))

[sqlalchemy] Showing only unused User Choices?

2009-06-25 Thread AF
Hello Assuming a table of Users, Choices and UserChoices... (many-to-many) How can I generate a list for a user showing only the choices they have _not_ opted in for? Thank you --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Goo

[sqlalchemy] Validators: Define at table / mapper level ?

2009-06-21 Thread AF
Hello, Can validators be defined at table / mapper level? (Is it even a good idea?) I ask, since it's at the table definition layer that I define what datatypes my columns have, so it seems natural to place the policing function there as well. :) --~--~-~--~~~---~-

[sqlalchemy] Random value for field by default?

2009-06-21 Thread AF
Hello, Perhaps this is more of a Python question that SQLalchemy.. but... How can I assign a random number to a DB field by default? I tried: default = random.randrange(1000,1) on the table definition, but I get the same number each time? Ideas? --~--~-~--~~~-

[sqlalchemy] "filtered" or "computed" version of an existing relation?

2009-06-17 Thread AF
tered" and "computed" version of an existing relation, how should I do this? See the code below. Thank you, AF Code: = users_table = Table('users', metadata, Column('id', Integer, primary_key=True),

[sqlalchemy] relation error?

2009-06-16 Thread AF
I'm probably just missing something... here is my code: engine = create_engine('sqlite:///:memory:', echo=True, convert_unicode=True) Session = sessionmaker(bind=engine) session = Session() metadata = MetaData() users_table = Table('users', metadata, Column('id', Integer,

[sqlalchemy] Can I coerce strings into Unicode?

2009-06-03 Thread AF
Hello, I'm using sqlite and "convert_unicode = True "on the engine. How can I force coerce string based object attributes in to unicode? (I had thought "convert_unicode = True" would do this) Here is what I am seeing... Setup code: engine = create_engine('sqlite:///:memory:', echo=True, conver

[sqlalchemy] SQLAlchemy as a FIFO buffer?

2009-05-18 Thread AF
Hello, I have several CGI and cron scripts and that I would like coordinate via a "First In / First Out" style buffer.That is, some processes are adding work units, and some take the oldest and start work on them. Since I need the queue to both survive system crashes and provide an audit rec