sqlalchemy

sqlalchemy REST serialization

Reading the doc of sqlalchemy, i saw the serialization part. I'm wondering about a possibility to use an xml serializer for matching sa models with Rest webservices like Jax-RS There is a django extension which deal with that : django_roa Do you know if that kind of thing has already been developped for sqlalchemy or if is it possible to...

Can SQLAlchemy update the table structure ?

Hello, I am working on my first pylons + SQLAlchemy app (I'm new to both). As I change my mind on the table structure, I wish there was a similar function to metadata.create_all(), that checks if there are new columns definitions and create theme in the database. Does such a function exist ? ...

Select statement with SqlAlchemy

Yes, very basic question. I've successfully created my db using declarative_base, and can perform inserts into the db too. I just have a few questions about SqlAlchemy sql statements. I've create a table called Location. A few issues/questions (see code below): For statement, "print row", I have to specify each column name that I wa...

How can I add new objects to FormAlchemy's Grid

I'd like to implement an "add row" button on some of my FormAlchemy grid forms to create objects. Reading through the source it would appear that there isn't this functionality at present so wondered if there's another project that does it, or if anyone has any pointers on how to do it? Cheers, Ben ...

Django: Is there an in_ lookup for querying model objects like there is for SQLAlchemy queries?

I'm trying to accomplish something like this: userSelectionIDs = [pref.selectionID for pref in UserColumnSelectionPreference.objects.filter(user=reqUser).all()] selections = ColumnSelections.objects.filter(id.in_(userSelectionIDs)).filter(type=2).all() Or, is there a better way for me to get that set of objects? ...

How to get sqlalchemy length of a string column

e.g. consider this simple table definition (using SQLAlchemy-0.5.6) from sqlalchemy import * db = create_engine('sqlite:///tutorial.db') db.echo = False # Try changing this to True and see what happens metadata = MetaData(db) user = Table('user', metadata, Column('user_id', Integer, primary_key=True), Column('name', String(...

Converting SQL commands to Python's ORM

How would you convert the following codes to Python's ORM such as by SQLalchemy? #1 Putting data to Pg import os, pg, sys, re, psycopg2 #conn = psycopg2.connect("dbname='tkk' host='localhost' port='5432' user='noa' password='123'") conn = psycopg2.connect("dbname=tk user=naa pass...

Example using BLOB in SQLAlchemy

Hi, does anybody have example how to use BLOB in SQLAlchemy? Regards, Steve ...

Creating container relationship in declarative SQLAlchemy

My Python / SQLAlchemy application manages a set of nodes, all derived from a base class Node. I'm using SQLAlchemy's polymorphism features to manage the nodes in a SQLite3 table. Here's the definition of the base Node class: class Node(db.Base): __tablename__ = 'nodes' id = Column(Integer, primary_key=True) node_type = Col...

Is there a Django's inspectdb equivalent for SQLAlchemy?

I've used Django's inspectdb command in the past, which gives you models from an existing database. Is there something equivalent for SQLAlchemy? ...

SQLAlchemy not returning selected data

I'm using SQLAlchemy as the ORM within an application i've been building for some time. So far, it's been quite a painless ORM to implement and use, however, a recent feature I'm working on requires a persistent & distributed queue (list & worker) style implementation, which I've built in MySQL and Python. It's all worked quite well un...

sqlalchemy does not create my foreign key

SqlAlchemy newbie question: Base = declarative_base() class A(Base): __tablename__ = 'as' id = Column(Integer, primary_key=True) class B(Base): __tablename__ = 'bs' id = Column(Integer, primary_key=True) a = relation(A) When I create my database schema, I have two tables, as and bs, which have one column (id) but...

Can I CREATE TEMPORARY TABLE in SQLAlchemy without appending to Table._prefixes?

I'd like to create a temporary table in SQLAlchemy. I can build a CREATE TABLE statement with a TEMPORARY clause by calling table._prefixes.append('TEMPORARY') against a Table object, but that's less elegant than table.select().prefix_with() used to add a prefix to data manipulation language expressions. Is there an equivalent to .prefi...

How do I INSERT INTO t1 (SELECT * FROM t2) in SQLAlchemy?

In SQLAlchemy, how do I populate or update a table from a SELECT statement? ...

Can SQLAlchemy's session.merge() update its result with newer data from the database?

The SQLAlchemy documentation says "session.merge() reconciles the current state of an instance and its associated children with existing data in the database". Does the existing object's state ever get updated by newer data from the database? How? When? ...

With sqlalchemy how to dynamically bind to database engine on a per-request basis

I have a Pylons-based web application which connects via Sqlalchemy (v0.5) to a Postgres database. For security, rather than follow the typical pattern of simple web apps (as seen in just about all tutorials), I'm not using a generic Postgres user (e.g. "webapp") but am requiring that users enter their own Postgres userid and password, ...

Avoiding MaxLocksPerFile via odbc connection to MS Access

Due to "circumstances beyond my control"tm, I am using sqlalchemy with an MS Access backend. I'm having an issue that the following code: def delete_imports(self, files_imported_uid): table_name = 'my_table' delete_raw = self.meta.tables[table_name].delete() self.engine.execute(delete_raw.where( self.meta.tables[tabl...

What's a good general way to look SQLAlchemy transactions, complete with authenticated user, etc?

I'm using SQLAlchemy's declarative extension. I'd like all changes to tables logs, including changes in many-to-many relationships (mapping tables). Each table should have a separate "log" table with a similar schema, but additional columns specifying when the change was made, who made the change, etc. My programming model would be some...

SQL Alchemy default value function for simulating autoincrement within a unique group of parent-child records

I have a small problem that I think should be easily handled by SQL Alchemy but I can't seem to get it right. I have two tables with one being a parent table and the other a child table. For each child record it needs a unique ID but only with the context of the unique parent record. I am using the Declarative Base approach. I setup ...

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 ...