I'm trying to do this:
class Foo(Base):
id = Column(Integer, primary_key=True)
class Bar(Foo):
id = Column(Integer, primary_key=True)
class FooBarAssociation(Base):
foo_id = Column(Integer, ForeignKey('foo_table.id'))
bar_id = Column(Integer, ForeignKey('bar_table.id'))
foo = relationship(Foo, backref=...)
bar...
Hey guys,
I have a problem when I import classes from one to another. I have
those classes in different modules:
crm.py
from CRMContactInformation import CRMContactInformation
class CRM(rdb.Model):
"""Set up crm table in the database"""
rdb.metadata(metadata)
rdb.tablename("crms")
id = Column("id", In...
A new requirement has come down from the top: implement 'proprietary business tech' with the awesome, resilient Elixir database I have set up. I've tried a lot of different things, such as creating an implib from the provided interop DLL (which apparently doesn't work like COM dlls) which didn't work at all. CPython doesn't like the MFC ...
Hello,
I get errors when I try to create tables one to one relation. Screen contains crm and crm contains more classes. The relation is one to one between crm, so I want to use the screen id as primary key in crm. And the relation is one to one between crm and some classes, I just added one class as example, so children of crm must cont...
Hello,
My needs :
I need to develop an GUI application that is cross platform
the chosen solution must be the fastest to implement
it should be easy to extend
The application is just a database front-end, mainly for CRUD operations, listing, filtering, exporting, charts and graphs etc.
After reading about some solutions (Python Car...
I have a very simple table(mapped as AuthToken class), consisting of a string ('token'), and a userid (foreign key to another table), with 'user' as relation ( = class User)
session.query(AuthToken.user).one() gives back the token, and the userid (as a tuple), but not the user object.
Does anybody know why?
thanks!
...
I know that some database drivers and other libraries providing connection to external services are incompatible with coroutine-based network libraries. However, I couldn't find out if SQLAlchemy can be safely used with such libraries (namely, gevent), and if any workarounds should be applied to exclude possible errors.
Can you either t...
I have a SQLAlchemy ORM model that currently looks a bit like this:
Base = declarative_base()
class Database(Base):
__tablename__ = "databases"
__table_args__ = (
saschema.PrimaryKeyConstraint('db', 'role'),
{
'schema' : 'defines',
},
)
db = Column(String, nullable=False)
role = Column(String, nullabl...
I'm storing JSON down as blob/text in a column using MySQL. Is there a simple way to convert this into a dict using python/SQLAlchemy?
...
I got a problem with PostGreSQL 8.4 and tables reflection. My metadata object seems to be ok (it has foreign keys, primary keys, every columns and tables). But when I try to associate an object to an another one through a Foreign key, I get : "sqlalchemy.exc.ProgrammingError: (ProgrammingError) can't adapt type 'EventParameters' 'INSERT ...
I am running Pylons using SQLAlchemy to connect to MySQL, so when I want to use a database connection in a controller, I can do this:
from myapp.model.meta import Session
class SomeController(BaseController):
def index(self):
conn = Session.connection()
rows = conn.execute('SELECT whatever')
...
Say my controller ...
Hey guys,
I have a doubt. I need to get the data from the sever twice every time when I load a page, one to render the HTML and another one to get the data for client side (javascript).
So I don't know exactly what it's the best way and fastest. I was trying to implement a session object and store the data once using joinedload loading...
I'm doing a join like this in SQLAlchemy:
items = Item.query\
.outerjoin((ItemInfo, ItemInfo.item_id==Item.id))
items.add_columns(ItemInfo.count)
This causes SQLAlchemy to return tuples:
>>> items.first()
(<Item ...>, 2)
I'd much prefer it if the "count" value would instead be returned as an attribute of the item, i.e. I wa...
Hello everyone!
This question is about how to design a SQL relationship. I am pretty newbie in this matter and I'd like to know the answers of (way) more experts guys...
I am currently migrating a ZopeDB (Object oriented) database to MySQL (relational) using MeGrok and SqlAlchemy (although I don't think that's really too relevant, sinc...
I need a query that can return the records from table A that have greater than COUNT records in table B. The query needs to be able to go in line with other filters that might be applied on table A.
Example case study:
I have a person and appointments table. I am looking for all people who have been in for 5 or more appointments. It mu...
I have a Pylons app that I'm using SqlAlchemy declarative models for. In order to make the code a bit cleaner I add a .query onto the SA Base and inherit all my models from that.
So in my app.model.meta I have
Base = declarative_base()
metadata = Base.metadata
Session = scoped_session(sessionmaker())
Base.query = Session.query_proper...
I am using Redis database where we store the navigational information. These data must be persistent and should be fetched faster. I don't have more than 200 MB data in this data set.
I face problem when writing admin modules for redis db and I really missing the sql schema and power of django style admin modules.
Now I am thinking of ...