1
vote
1answer
6 views

Many-Many Relationship in SQL Alchemy

I have a many to many relationship defined in SQLAlchemy tweet2user = db.Table('tweet2user', db.Column('tweet_id', db.Integer, db.ForeignKey('users.uid')), db.Column('user_id', db.Integer, ...
3
votes
1answer
11 views

SQLAlchemy eager load specific subtype collection

I have this (simplified) user / group model in one of my projects: import sqlalchemy import sqlalchemy.ext.declarative import sqlalchemy.orm import sqlalchemy.schema Base = ...
0
votes
0answers
7 views

SqlAlchemy many to many deletes on two levels

I'm not entirely sure how to classify the relationship I have in my data, so I just write "two levels" many to many. To clarify the actual class definitions are included on the bottom. Anyway my ...
1
vote
1answer
14 views

SQLAlchemy commits makes float to be rounded

I have a schema with a Float column, something like this: Base = declarative_base() class Table(Base): __tablename__ = 'table' id = Column(Integer,primary_key=True) amount = ...
0
votes
0answers
15 views

ORA-01400 in sqlalchemy while trying to commit

I want to add new row's in DB using SQLAlchemy. Table is rather big (have many columns), so I serialize rows in yaml files, and than convert into rows again and try to insert. Here is the class of ...
1
vote
1answer
16 views

SQLAlchemy - How can I make eager loading count property

I want to make a property for model which contains count. Since I always need the property, I want to make query with JOIN like sqlalchemy.orm.relationship with lazy='joined' For example, I defined ...
1
vote
1answer
8 views

SQLAlchemy Returning UTF-8 as Latin1 Strings

I have a MySQL database encoded in UTF-8, but when I connect to it with SQLAlchemy (Python 2.7), I get back strings with Latin1 Unicode characters in them. So, the Dutch spelling of Belgium (België) ...
0
votes
0answers
10 views

How to set a default value from a SQLAlchemy relationship?

I have a set of classes defined like this: class CrosstabCohort(Base): __table__ = crosstab_cohorts # has property is_column cohort = relationship(Cohort, innerjoin=True) class ...
1
vote
1answer
32 views

How to write multi column in clause with sqlalchemy

Please suggest is there way to write query multi-column in clause using SQLAlchemy? Here is example of the actual query: SELECT url FROM pages WHERE (url_crc, url) IN ((2752937066, ...
1
vote
2answers
48 views

Flask-SQLAlchemy Constructor

in the Flask-SQLAlchemy tutorial, a constructor for the User model is defined: from flask import Flask from flask.ext.sqlalchemy import SQLAlchemy app = Flask(__name__) ...
0
votes
1answer
34 views

Flask SQLAlchemy filter records from foreign key relationship

I have 2 models: class Scenario(db.Model): __tablename__ = 'scenarios' scenario_id = db.Column(db.Integer, primary_key=True) scenario_name = db.Column(db.String(120)) scenario_text = ...
1
vote
1answer
35 views

“pip install SQLAlchemy” Results in “fatal error: Python.h: No such file or directory”

Calling pip install SQLAlchemy I get an error: lib/sqlalchemy/cextension/processors.c:10:20: fatal error: Python.h: No such file or directory As far as I know, I have the correct Python version ...
0
votes
1answer
55 views

Local MySQLdb connection fails with AttributeError for paramstyle when running GAE development server

I'm building a GAE Flask application with Flask-Alchemy, against Cloud SQL, and running dev_appserver to test the application as I build it. However, if I set the SQLALCHEMY_DATABASE_URI to a ...
0
votes
0answers
28 views

sqlalchemy select fields how to choice

I user join realize left join but the sqlalchmey don't selec * query = session.query(*args) #args is the Table models.Aggregate rows = query.join((models.Aggregate, ...
0
votes
1answer
15 views

How to find the newest entry for each of “n” with sqlalchemy

I'm working on fixing up a forum script of mine, and I want to do what many popular sofwares do and display the latest reply for each board category on the category list. I just can't seem to get ...
0
votes
1answer
19 views

make query ManyToMany in sqlalchemy?

in sqlalchemy,the models like this: class User(Base): id = Column(IdDataType, primary_key=True) name = Column(Unicode(50)) class Group(Base): id = Column(IdDataType, primary_key=True) ...
0
votes
1answer
15 views

SQLAlchemy, how many rows were commited on last commit

Is there a way to know how many rows were commited on the last commit on a SQLAlchemy Session? For instance, if I had just inserted 2 rows, I wish to know that there were 2 rows inserted, etc.
1
vote
0answers
28 views

SQLAlchemy: Join to subquery with no from field

I have a table called product_model with its corresponding ProductModel SQLAlchemy model. I wish to join the product_model table to a select sub query which simply unnests two PostgreSQL arrays ...
0
votes
0answers
24 views

sqlalchemy table reflection not setting the default charset

I'm trying to figure out how to specify a default character set for a sqlalchemy table built reflectively. Some of our tables have columns which are latin1, and some are utf8. I could create a table ...
0
votes
1answer
18 views

Alembic bulk_insert to table with schema

I'm looking at the example at bulk_insert. # Create an ad-hoc table to use for the insert statement. accounts_table = table('account', column('id', Integer), column('name', String), ...
0
votes
0answers
23 views

SqlAlchemy add tables versioning to existing tables

Imagine that I have one table in my project with some rows in it. For example: # -*- coding: utf-8 -*- import sqlalchemy as sa from app import db class Article(db.Model): __tablename__ = ...
0
votes
0answers
22 views

Generic TEXT/CLOB data type for cross-database SQLAlchemy application

I am working on Python web application that uses MySQL as a database backend on the development environment and Oracle 11g on the production environment. Is there a specific way to unify the ...
0
votes
2answers
86 views

Writing SQL query refering same table twice

Consider the following table definitions class MCastSession(Base): __tablename__ = 'mcast_session' id = Column(Integer, primary_key=True) ip = Column(Integer) port = Column(Integer) ...
1
vote
2answers
33 views

SQLAlchemy autoload insert record

PostgreSQL has table student: Table "public.student" Column | Type | Modifiers ...
0
votes
1answer
29 views

SQLalchemy: changes not committing to db (solved)

I am trying to write what should be a relatively simple script using SQLalchemy to interact with a MySQL database. I am pretty new to sqlalchemy, and programming in general, so I am in need of help. ...
2
votes
0answers
17 views

Creating custom sqlalchemy types

I am trying to save ipaddress in a table. Created a custom type as follows: class MCastIP(sqlalchemy.types.TypeDecorator): impl = sqlalchemy.types.Integer def process_bind_param(self, value, ...
0
votes
1answer
22 views

Postgres ILIKE Query with Flask/SQLAlchemy

I have the following model: class Post(db.Model): id = db.Column(db.Integer, primary_key = True) title = db.Column(db.String(250)) content = db.Column(db.String(5000)) I'd like to run a ...
0
votes
1answer
25 views

sqlalchemy FULL OUTER JOIN

How to implement FULL OUTER JOIN in sqlalchemy on orm level. Here my code: q1 = (db.session.query( tb1.user_id.label('u_id'), func.count(tb1.id).label('tb1_c') ) ...
0
votes
0answers
23 views

gevent and SQLAlchemy MySQL compatible driver [closed]

I'm working on a project which relies on gevent for concurrency and needs to work with a MySQL DB. I would like to use SQLAlchemy although I have to say it is not a strict requirement. Using a MySQL ...
1
vote
1answer
21 views

Optimize order by random() in table with lot of records

I am using SQLAlchemy to fetch one random result (from count results I choose only one based on some stuffs/ this cannot be on sql level choosing) which satisfies conditions, my query looks like for ...
0
votes
1answer
52 views

What's faster: temporary SQL tables or Python dicts for session data?

Have some programming background, but in the process of both learning Python and making a web app, and I'm a long-time lurker but first-time poster on Stack Overflow, so please bear with me. I know ...
0
votes
0answers
25 views

Relationship id doesn't saved in sqlalchemy one-to-many relation

I'm learning Flask with SQLAlchemy, and I have created a relationship as described in the page: class Parent(Base): __tablename__ = 'parent' id = Column(Integer, primary_key=True) ...
0
votes
0answers
24 views

in openstack loadbalancer not able tget_members with filters

Was trying to get the members belonging to a pool and trying to use def get_members(self, context, filters=None, fields=None): I was calling this function as ...
0
votes
0answers
32 views

How can I generate additional attributes in a python class based on existing ones?

I have a class in SQLAlchemy that stores contact details for my users: # UserExtension extension creates a ForeignKey and relationship to users # which is also the PK class Contact(UserExtension, ...
1
vote
2answers
35 views

How to implement session.add on this code:

So, I need some help to make this script run faster, below is my script. #!/usr/bin/env python import glob,os, csv from sqlalchemy import * count = 0 served_imsi = [] served_imei = [] served_msisdn ...
2
votes
1answer
22 views

How to use “CONVERT” function in SqlAlchemy?

I tried: from sqlalchemy import VARCHAR result = session.query(Table).filter(func.convert(VARCHAR(8), Table.datetimefiedld, 8) >= some_date).all() I got AttributeError: 'VARCHAR' object has no ...
3
votes
1answer
33 views

SQLAlchemy query, join on relationship and order by count

I have two SQLAlchemy models set up as follows: ############## # Post Model # ############## class Post(db.Model): id = db.Column(db.Integer, primary_key = True) title = ...
-2
votes
1answer
39 views

Decorator to store function name to file and delete if there is no error

I have lot of functions with various parameters, inside I am doing something ike this session = Session() try: # do something with parameters except Exception as e: print e.message ...
0
votes
1answer
23 views

How do I do a “starts with” query using SQL alchemy?

I am learning to use SQL alchemy to connect to a mysql database. I want to pull records from the DB that start with a given string. I know that for simple equality all I need to do is this queryRes = ...
2
votes
1answer
26 views

mysql query to sqlalchemy version

Myself getting familiar with sqlalchemy.I have a mysql query as below: SELECT COUNT( * ) AS total, SUM( IF(sub = 'N', 1, 0 ) ) AS NotSubscribed, SUM( IF( subscription = 'A', 1, 0 ) ) AS 12Month, ...
0
votes
2answers
41 views

filtering time range in datetime field in sqlalchemy

I got a weird problem when I was doing the time range filtering in sqlalchemy. There is a datetime column in Event table called startDate. I was writing the query to return all the events that have ...
0
votes
1answer
32 views

sqlalchemy: cannot save model with Date column

I have created a model via declarative_base: Base = declarative_base() class Record(Base): __tablename__ = 'test' id = Column(BigInteger, primary_key=True) datefrom = Column(Date) ...
0
votes
0answers
53 views

Python/SQL Alchemy Migrate - “ValueError: too many values to unpack” when migrating changes in db

I have several models in SQLAlchemy written and I just started getting an exception when running my migrate scripts: ValueError: too many values to unpack Here are my models: from app import db ...
0
votes
1answer
27 views

create_or_get entry in a table

I have two related classes as below: class IP(Base): __tablename__ = 'ip' id = Column(Integer, primary_key=True) value = Column(String, unique=True) topics = relationship('Topic') ...
1
vote
1answer
31 views

sqlalchemy inconsistent row updates

each of the following functions fails to update the record ~10% of the time. What am I not understanding about sqlalchemy? THANKS! def update_field_1 ( session, rec ): rec.field1 = 'hello' ...
1
vote
0answers
19 views

Setting attribute on an sqlachemy instance breaks Mapping

I have a class that inherits from collections.Mapping and in the same time is mapped with sqlalchemy.orm.mapper. I do this for the convenience of ...
0
votes
1answer
28 views

Python Camelot/sqlalchemy: performing math on Select

I'm using Python Camelot, which uses sqlalchemy and sqlite under the hood. I am storing hours as an integer to avoid floating point errors. For example, 1 hour is stored in the database as 100, 2.5 ...
0
votes
0answers
33 views

Property set only to last element of array [Python]

I have an array calls of Call objects. Each Call is a SQLAlchemy model, inherited from declarative_base() and has property record_url, not associated with stored column: Base = ...
0
votes
1answer
17 views

Why would we need to have multiple search vectors per class? (sqlalchemy-searchable)

I was going through the sqlalchemy-searchable docs and they have provision for multiple search vectors for same class. Why would this be useful? for example (from the docs) class Article(Base): ...
1
vote
3answers
5k views

using Mysql and SqlAlchemy in Pyramid Framework

Pyramid Framework comes with a sample tutorial of sql alchemy that uses sqlite. The problem is that i want to use mysql so i change this sqlalchemy.url = sqlite:///%(here)s/tutorial.db Into this ...

15 30 50 per page