0
votes
0answers
14 views

How do I create a one-to-many relationship with a default one-to-one property for I18N

Suppose we have these classes: class Item(Base): id = Column(Integer, primary_key=True) data = Column(String) i18ns = relationship("ItemI18n", backref="item") class ItemI18n(Base): ...
0
votes
1answer
22 views

SQLAlchemy joining issue (continuous joining)

Didn't quite know how to explain it in the title, but here is what I'm facing. I need to write, what I thought was a relatively straight forward query (well in SQL anyway): SELECT tasks.*, ...
0
votes
1answer
41 views

Modeling human relationships

I'm looking for the best way to define relationships between two people and query it in SQLAlchemy. I'm having a hard time wrapping my head around this. Here is what I have so far but I don't know if ...
0
votes
1answer
10 views

sqlalchemy.exc.CircularDependencyError: Circular dependency detected

The business logic - One Category may have multiple (1:M) attributes, like Category "Memory" could have attributes Speed, Size, Type etc. at the same time one Category could be sorted by the ...
0
votes
1answer
14 views

SQLAlchemy gives error Exception: No searchable columns defined for model Post

Here is my models.py from app import db from sqlalchemy.ext.declarative import declarative_base from sqlalchemy_searchable import Searchable from sqlalchemy_utils.types import TSVectorType Base = ...
0
votes
1answer
18 views

can't insert into one-to-many relationship in sqlalchemy

I have a one to many relationship in sqlalchemy but I don't get the inserts to work properly. I have tried to make a minimal example here: from sqlalchemy import * from sqlalchemy.ext.declarative ...
1
vote
1answer
25 views

how to query sqlalchemy by month name

I tried this db_session.query(PaymentsMade).filter(func.strftime('%B', PaymentsMade.created_at) == "August").all() but am getting this error (ProgrammingError) function strftime(unknown, ...
0
votes
1answer
15 views

SQL Alchemy: SQL syntax error on add with session

I'm currently stuck with the following error when I try to perform an add using a session with SQLAlchemy. sqlalchemy.exc.ProgrammingError: (ProgrammingError) (1064, "You have an error in your SQL ...
0
votes
1answer
17 views

SQLAlchemy count followers to a tag

Say I have a tag model: class tag(db.Model): id = db.Column(db.Integer, primary_key = True) name = db.Column(db.String(240)) def FollowerRanked(self): #return ...
0
votes
1answer
13 views

SQLAlchemy - How to count open sessions?

Is there a way to get the number of open database sessions with SQLAlchemy? Say I want to run some tests against my app to make sure I'm properly closing all of the sessions that I open. I tried ...
-1
votes
0answers
34 views

Tests with Celery and Sqlalchemy Session

I have legacy code similar to the following do_something.py from models import MyModel from models import db_session # scoped session created and configured somewhere else def do something(a,b,c): ...
0
votes
1answer
12 views

How do I handle “out of range” warnings for timezone-aware datetime objects on MySQL with and without SQLAlchemy

I receive a warning from Mysql-Python when inserting a timezone-aware datetime object into a DateTime column on MySQL: test_mysql.py:13: Warning: Out of range value for column 'created_at' at row 1 ...
2
votes
1answer
27 views

SQLAlchemy subquery in from clause without join

i need a little help. I have following query and i'm, curious about how to represent it in terms of sqlalchemy.orm. Currently i'm executing it by session.execute. Its not critical for me, but i'm just ...
1
vote
1answer
36 views

How to set query which has condition not in?

How to set query which has condition not in ? I get from client list of ids (ids is list of numbers) and I need to returns only one user with different id (id of new user is not in passed list). user ...
1
vote
1answer
15 views

SQLAlchemy eager loading collection size / count

SQLAlchemy can eagerly load the contents of the collection if I specify the joinedload option. However, I have a case where I'm not actually interested in the contents of the collection, just the ...
0
votes
1answer
15 views

How can I return a query in ResultProxy format when using SQLAlchemy ORM?

I find ResultProxy more convenient to use than ORM results in some cases (by the docs I understand that I could iterate the columns in a full table). I tried this: query = session.query(Table1) ...
0
votes
0answers
11 views

How to set the default Column subclass that SQLAlchemy's autoload should use?

I am subclassing some of SQLAlchemy's classes to provide additional functionality. I have already a database, and sometimes, just for speed, I use autoload. I have made it work with queries: ...
0
votes
1answer
21 views

SQLAlchemy returns an integer

I am accessing a database using SQLAlchemy. When I try to filter the table using a bunch of public and private keys I get an Attribute error saying 'int' object has no attribute 'date'. Sometimes, I ...
0
votes
1answer
31 views

Way to filter using a backref “length” with SQLAlchemy

I have a one-to-many relationship between two types of objects Message and URL. A relationship is defined in the class URL with a backref named "link" that points to Message. Is there a way to make a ...
1
vote
1answer
40 views

SQLAlchemy show me that “AttributeError: type object 'User' has no attribute 'columns'”

I am building a small project use python+Flask+SQLAlchemy, I make a model file following: ################# start of models.py ##################### from sqlalchemy import Column, Integer, String, ...
0
votes
1answer
13 views

SQLAlchemy-serialize values into column of table

I'm working on a project in SQLAlchemy. I've got Command class which has custom serialization/deserialization method called toBinArray() and fromBinArray(bytes). I use it for TCP communication (I ...
0
votes
0answers
23 views

SQLAlchemy “client-side views”

I have a somewhat complex SQL table structure that is only really useable when joining multiple tables together. I'm using SQLAlchemy and Postgres and was wondering whether it is possible (or someone ...
0
votes
1answer
18 views

Is safe to pass session as parameter into inner function to avoid zombie sessions and pool overflow?

I am fairly new to SQLAlchemy and I wonder what is a right style to write code with sessions and splitting sqlalchemy queries into couple functions and to avoid zombie sessions in case of any ...
0
votes
0answers
45 views

Slugs in SQLAlchemy, Pyramid, and Python 3

I'm using Python 3.3.1, the latest versions of Pyramid and SQLAlchemy, and I think I'm having some Unicode issues. I have a database model set up like this: class Blah(Base): __tablename__ = ...
1
vote
0answers
24 views

creating tables from different models with sqlalchemy

I have different models e.g. model1.py, model2.py etc. Some how tables are being created following pocoo link, which required to be invoked from terminal. But def init_db(): import ...
0
votes
0answers
22 views

Efficient SQLAlchemy Query [duplicate]

Consider the following table: Name | Timestamp | Value a | 00412 | bbbb a | 23123 | ffff c | 23124 | asdf ..... I want to create a query in SQLAlchemy that is capable of ...
0
votes
0answers
32 views

One to many relationship issue with sqlalchemy

I have defined my models like so: class Publisher(db.Model): __tablename__ = 'publishers' # __table_args__ = {'extend_existing': True} # IDs id = db.Column(db.Integer, ...
0
votes
0answers
20 views

Properly designing sqlalchemy relationships: can't access child data

I'm hoping someone can help me diagnose the code below. I'm trying to create a one to many relationship between Company and Prices, where the latter tracks daily stock prices. This is my first time ...
0
votes
0answers
80 views

can I join in raw numbers to a sql query?

This is sort of a weird question, so I don't really know how to phrase it or begin searching for answers. Sorry for wall of text. The situation (which is unfortunately complicated enough to start ...
0
votes
1answer
18 views

Getting “Invalid cursor state (0)” when running concurrent requests (SQLAlchemy & wsgi/python)

I'm using SQLAlchemy in WSGI python web app to query the database. If I do two concurrent requests, the second request invariably throws an exception, with SQL Server stating [24000] [FreeTDS][SQL ...
1
vote
1answer
11 views

Override return values of a column in SQLAlchemy; hybrid property or custom type?

I would need a very quick advice. I have a table field which can contain NULL, one or more strings, separated by ';'. At the moment the column is defined in the model as usual: aliases = ...
3
votes
1answer
41 views

How to exclude specific fields on serialization with jsonpickle?

I'm using SQLAlchemy extension with Flask. While serializing my models (which are also used for database operations) using jsonpickle, I want some specific attributes to be ignored. Is there a way ...
0
votes
0answers
28 views

why this happens, I'm using flask and sqlalchemy? <Post at 0x102909c10>' is already attached to session '1' (this is '6')

flask-sqlalchemy/many-to-many tag_post = db.Table('tag_post', db.Column('tag_id', db.Integer, db.ForeignKey('tag.id', ondelete='CASCADE')), db.Column('post_id', db.Integer, db.ForeignKey('post.id', ...
0
votes
0answers
14 views

sqlalchemy multiple join conditions through association proxy

I have three structures with data at each possible relationship point between them (call them a, b, and c). I declare these relations (with the associated tables) like so... class A(Base): ...
0
votes
1answer
23 views

Determine if a property is a backref in sqlalchemy

I have the following relationship set up in a model: role_profiles = Table('roleprofile', Base.metadata, Column('role_id', Integer, ForeignKey('role.id')), ...
0
votes
1answer
27 views

SqlAlchemy and getting roles for my user through double relationship

I have three tables: profile id, int, pk name... role id, int, pk name ... profilerole role_id int, pk, foreign_key to role.id profile_id int, pk, foreign_key to role.id I want ...
2
votes
2answers
29 views

sqlalchemy map object which contains dicts

I'm trying to map an object that looks like this: self.user = {lots of stuff in here} self.timeStamp = i am a date object self.coordinates = {lots of stuff in here} self.tweet = ...
1
vote
2answers
31 views

Getting first row from sqlalchemy

I have the following query: profiles = session.query(profile.name).filter(and_(profile.email == email, profile.password == password_hash)) How do I check if there is a row and how do I just return ...
3
votes
0answers
29 views

Threading and SQLAlchemy Sessions

I know this question has been asked a few times, but I'm still unsure about the usage of scoped_session with threading. Basically, I have an application with 10 worker threads. I have one Engine with ...
0
votes
1answer
34 views

How do I implement a null coalescing operator in SQLAlchemy?

Or how do I make this thing work? I have an Interval object: class Interval(Base): __tablename__ = 'intervals' id = Column(Integer, primary_key=True) start = Column(DateTime) end = ...
2
votes
2answers
56 views

How to represent hierarchy in SQL database

I need to represent hierarchy of geographical objects in my database. Each object have a name and geographical coordinates (lat/lon). The 1st level of hierarchy may be one of two possible values: ...
2
votes
2answers
93 views

Python SQLAlchemy - “MySQL server has gone away”

Lets have a look at the next snippet - @event.listens_for(Pool, "checkout") def check_connection(dbapi_con, con_record, con_proxy): cursor = dbapi_con.cursor() try: cursor.execute("SELECT 1") ...
0
votes
0answers
30 views

For changed SQLAlchemy model in Python what are appropriate types in MySQL to support mapping

I have altered table after put into production server. Now I need that change to add to server. I am using SQLAlchemy, and if I understood well there is no support in SQLAlchemy to alter tables. I ...
0
votes
0answers
56 views

sqlalchemy __getattr__ and __setattr__ for dict based columns

The above may not be the best description in the world of what I am wanting to achieve but hopefully the code below will be enough of an example. The end result is that I am trying to work the php cms ...
0
votes
1answer
61 views

sqlalchemy integrity error

I have a table where the primary key (id) isn't the key by which i distinguish between records. For this, I have a unique constraint for 3 columns. In order to be able to merge records, I've added a ...
0
votes
0answers
22 views

UPDATE using sqlalchemy MODEL

I have a table "user_table" in my model which is represented by UserTable in my MSSQL database and I want to use the Model to execute a update query. (Set a bit field IsSent which is NULL to 1 (True)) ...
1
vote
1answer
22 views

Does adding sqlalchemy.orm.relationship to a model changes internal DB schema?

Does adding sqlalchemy.orm.relationship to a model changes internal DB schema? Do I need to add a DB migration script if the only thing that has changed in the ORM mapping is the orm.relationship ...
1
vote
0answers
36 views

SQLAutoCode - error when attempting to generate schema

I'm trying to auto generate a schema for use in SQLalchemy, I'm using sqlautocode to do this, I use the following command D:~ admin$ sqlautocode mysql://'user':"pass"@xx.xx.xx.xx:3306/db_name -o ...
4
votes
4answers
3k views

Admin interface for SQLAlchemy?

I've been developing a Django app, however I've recently changed the overall architecture plan. I no longer need a web-framework, just a simple Python script, so I'm changing from using the Django ORM ...
47
votes
3answers
9k views

What's the difference between filter and filter_by in SQLAlchemy?

Could anyone explain the difference between filter and filter_by functions in SQLAlchemy? I am confused and can't really see the difference. Which one should I be using?

1 2 3 4 5 48
15 30 50 per page