I'm writing an Fast-CGI application that makes use of sqlAlchemy & MySQL for persistent data storage. I have no problem connecting to the DB and setting up ORM (so that tables get mapped to classes); I can even add data to tables (in memory).
But, as soon as I query the DB (and push any changes from memory to storage) I get a 500 Int...
can i do:
table.relationship.filter( column = value )
to get a subset of rows for relationships? and the same for order_by?
...
We have a need to create SQLAlchemy classes to access multiple external data sources that will increase in number over time. We use the declarative base for our core ORM models and I know we can manually specify new ORM classes using the autoload=True to auto generate the mapping.
The problem is that we need to be able generate them dy...
Is there a migration guide for the the models aspect in pylons, syntax with SQLAlchemy to MongoDB?
...
I am looking for a way to introspect SQLAlchemy ORM classes/entities to determine the types and other constraints (like maximum lengths) of an entity's properties.
For example, if I have a declarative class:
class User(Base):
__tablename__ = "USER_TABLE"
id = sa.Column(sa.types.Integer, primary_key=True)
fullname = sa.Colu...
I'm writing a Pylons app, and am trying to create a simple backup system where every table is serialized and tarred up into a single file for an administrator to download, and use to restore the app should something bad happen.
I can serialize my table data just fine using the SqlAlchemy serializer, and I can deserialize it fine as well...
i have functions that look like this that is littered through out the code
def get_M_status(S):
M_id = marital.select(marital.c.marital_status_description == S).execute().fetchone()
if M_id == None:
print "Warning: No Marital id found for %s Marital status to Single" % S
M_id = marital.select(marital.c.marital_...
I'm running into this little problem that I hope is just a dumb user error. It looks like some sort of a size limit with a query to a SQLite database. I managed to reproduce the issue with an in-memory DB and a simple script shown below. I can make it work by either reducing the number of records in the DB; or by reducing the size of eac...
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...
Hi,
I'm using sqlalchemy with Elixir and have some troubles trying to make a query..
I have 2 entities, Customer and CustomerList, with a many to many relationship.
customer_lists_customers_table = Table('customer_lists_customers',
metadata,
Column('id', Integer, primary_key=True),
...
I am new to SQLAlchemy (and SQL, for that matter). I can't figure out how to code the idea I have in my head.
I am creating a database of performance-test results.
A test run consists of a test type and a number (this is class TestRun below)
A test suite consists the version string of the software being tested, and one or more TestRu...
I have a large sql dump file ... with multiple CREATE TABLE and INSERT INTO statements. Is there any way to load these all into a SQLAlchemy sqlite database at once. I plan to use the introspected ORM from sqlsoup after I've created the tables. However, when I use the engine.execute() method it complains: sqlite3.Warning: You can only...
Dear everyone, I am following the Many to many relationship described on http://www.sqlalchemy.org/docs/mappers.html#many-to-many
#This is actually a VIEW
tb_mapping_uGroups_uProducts = Table( 'mapping_uGroups_uProducts', metadata,
Column('upID', Integer, ForeignKey('uProductsInfo.upID')),
Column('ugID', Integer, ForeignKey('uGr...
Hi everyone,
I've updated SQLAlchemy to 0.6 but it broke everything. I've noticed it returns tuple not a dictionary anymore. Here's a sample query:
query = session.query(User.id, User.username, User.email).filter(and_(User.id == id, User.username == username)).limit(1)
result = session.execute(query).fetchone()
This piece of code use...
I'm trying to get multiple image paths from my database in order to display them, but it currently doesn't work.
Here's what i'm using:
def get_image(self, userid, id):
image = meta.Session.query(Image).filter_by(userid=userid)
permanent_file = open(image[id].image_path, 'rb')
if not os.path.exists(image.image_path):
...
To provide an activity log in my SQLAlchemy-based app, I have a model like this:
class ActivityLog(Base):
__tablename__ = 'activitylog'
id = Column(Integer, primary_key=True)
activity_by_id = Column(Integer, ForeignKey('users.id'), nullable=False)
activity_by = relation(User, primaryjoin=activity_by_id == User.id)
ac...
what is the difference between declaring the cascade within a foreign key vs relations?
class Contact(Base):
__tablename__ = 'contacts'
id = Column(Integer, primary_key=True)
addresses = relation("Address", backref="contact")
class Address(Base):
__tablename__ = 'addresses'
id = Column(Integer, primary_key=True)
...
Is it possible to have multi-level polymorphism in SQLAlchemy? Here's an example:
class Entity(Base):
__tablename__ = 'entities'
id = Column(Integer, primary_key=True)
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
entity_type = Column(Unicode(20), nullable=False)
__mapper_args__ = {'polymorph...
I'm trying to create a db structure in which I have many types of content entities, of which one, a Comment, can be attached to any other.
Consider the following:
from datetime import datetime
from sqlalchemy import create_engine
from sqlalchemy import Column, ForeignKey
from sqlalchemy import Unicode, Integer, DateTime
from sqlalchemy...
Currently, i am querying with this code: meta.Session.query(Label).order_by(Label.name).all()
and it returns me objects sorted by Label.name in this manner ['1','7','1a','5c']. Is there a way i can have the objects returned in the order with their Label.name sorted like this ['1','1a','5c','7']
Thanks!
...