0
votes
2answers
18 views

SQL alchemy case insensitive sort order

Hi Im trying to achieve a ascending sort order for particular columns in a sqlite database using sql alchemy, the issue im having is that the column I want to sort on has upper and lower case data and ...
0
votes
0answers
11 views

SqlAlchemy: Composite column types including relationship

I created a Composite type to represent Quantities, like 100 kilos or 100 pounds (a pair amount, unit). The problem here is that unit references a mapped class stored in the Unit table. When I create ...
0
votes
0answers
13 views

SQLAlchemy events after_create for all models

I'm working on a project that requires generic customisation to every model that is created. The way I have done most of the work to date is by model inheritance. Here is my code block to give you a ...
0
votes
3answers
15 views

find missing value between to tables in sqlalchemy

I have two tables with a common field I want to find all the the items(user_id's) which present in first table but not in second. Table1(user_id,...) Table2(userid,...) user_id in and userid ...
0
votes
0answers
14 views

Using factory_boy with SQLAlchemy and class methods

I am working on a Pyramid app with SQLAlchemy as the ORM. I am trying to test a model with a class method: # this is essentially a global used by all the models Session = ...
0
votes
1answer
23 views

Efficient update, insert on fail, with sqlalchemy

I essentially need to do an INSERT ... ON DUPLICATE KEY UPDATE however the row will already exist 99.9...% of the time. Therefore, what I really want to do is an UPDATE, catch the odd exception and ...
0
votes
1answer
20 views

SQLAlchemy Concurrency and Queries

I have a number of separate machines, each of which uses a separate instantiation of Session = scoped_session(sessionmaker(bind=engine)). If machine A runs the code session = Session() ...
0
votes
1answer
42 views

global name 'unhex' is not defined

I am working on flask and on executing this statement salt=os.urandom(32) db_session.execute('insert into posUsers values (?, ?, ?, ?)',[usern,unhex("sjg"),salt,row.clientId]) its giving this ...
2
votes
1answer
32 views

Ordering by subquery in SQLAlchemy

I'm trying to select the newest threads (Thread) ordered descending by the time of the most recent reply to them (the reply is a Post model, that's a standard forum query). In SQL I'd write it like ...
0
votes
0answers
31 views

sqlalchemy insert statement giving error “has no attribute insert”

I am trying to insert a row in my table posUsers posUsers.insert().values(usern,unhex(finalhash),unhex(salt),row.clientId) but its giving error "posUsers has no attribute insert "
1
vote
1answer
25 views

What is the correct syntax to search an HSTORE column with SQLAlchemy ORM (0.8)?

I am using flask w/ flask-sqlachemy extension. Am attempting to search for all records that have an hstore key with a certain value. Here is what the column is set up as: from flask.ext.sqlalchemy ...
0
votes
1answer
20 views

WTForms QuerySelectMultipleField Not sending List

I am working on a Flask Application to do some event scheduling. I am having problems with WTForms QuerySelectMultipleField in my form. forms.py class EnterEvent(Form): ... invitees = ...
0
votes
1answer
12 views

SQLAlchemy Core Connection Context Manager

Can I use a context manager for SQLAlchemy Core connections? In other words, is conn = engine.connect() conn.execute('SELECT * FROM FOO') conn.close() the same as with engine.connect() as conn: ...
2
votes
0answers
120 views

SQLAlchemy ─ Mapping a Class against Multiple Tables

# ! /usr/bin/env python # -*- coding: utf-8 -*- # login_frontend.py """ Python 2.7.3 Cherrypy 3.2.2 PostgreSQL 9.1 psycopy2 2.4.5 SQLAlchemy 0.7.10 """ I'm ...
1
vote
0answers
52 views

Sqlalchemy dynamic creation of children

It is necessary to create a model of children with different methods. I decided to do a meta class: class AProxy(object): #some methods class BProxy(object): #some methods class ...
2
votes
0answers
25 views

How to fetch referenced entities with SQLAlchemy?

I have a question concerning the mapping of entities in SQLAlchemy. I have a transient object, which already contains foreign keys to some persistent objects. I want that SQLAlchemy fetches the ...
0
votes
0answers
16 views

How do I connect to an SQL Database from a python program using SQLAlchemy?

So i'm trying to connect to a database on a server, not on the same computer i'm running the code from. And i can't do it. I've looked at the documentation for connect strings, and as far as i can ...
0
votes
1answer
16 views

SQLAlchemy example “Handling Multiple Join Paths” throws an exception

I'm trying to do something similar to the example in: http://docs.sqlalchemy.org/en/rel_0_8/orm/relationships.html#handling-multiple-join-paths When I execute the following script: ...
0
votes
1answer
22 views

Can't catch _mysql_exceptions.OperationalError in Flask app

I have a Flask app with a route that looks like this: from _mysql_exceptions import OperationalError @mod.route('/', methods=['POST']) def do_something_route(): try: ...
1
vote
1answer
63 views

SQLAlchemy Relationship Error: object has no attribute 'c'

I used sqlautocode to generate my model and all the relationships. I'm trying to do a simple query like obj = session.query(Venue).filter(Venue.symbol=="CARNEGIE_HALL").one() For some reason I ...
0
votes
1answer
23 views

Dynamic join sqlalchemy

I want to dynamically join a certain number of tables from a list containing table names, for example if my list contains two elements like this : tables_to_join = ['table1','table2'] Then I would ...
3
votes
1answer
35 views

How can I load initial data into a database using sqlalchemy

I want to be able to load data automatically upon creation of tables using SQLAlchemy. In django, you have fixtures which allow you to easily pre-populate your database with data upon creation of a ...
0
votes
0answers
31 views

Is it possible to run cross database query on my sql from python?

I'm trying to implement database clone function with python and sqlalchemy. The goal is cope database {old_db_name} to {new_db_name}. When I did: I switched database to {new_db_name}: use ...
0
votes
1answer
8 views

SQLAlchemy: Initializing attribute based on other attribute

I'm working on a Python project using SQLAlchemy. I have following class (I have omitted some methods irrelevant to the question): class Cmd(Base): __tablename__ = "commands" dbid = ...
1
vote
0answers
71 views

Parsing and constructing filtering queries similiar to SQL WHERE clause in Python/JavaScript

I am building a query engine for a database which is pulling data from SQL and other sources. For normal use cases the users can use a web form where the use can specify filtering parameters with ...
1
vote
1answer
20 views

How to define metaclass for a class that extends from sqlalchemy declarative base

I use: Python 2.6 and sqlalchemy 0.6.1 This is what I am trying to do: from sqlalchemy.types import ( Integer, String, Boolean ) from sqlalchemy.ext.declarative import declarative_base ...
0
votes
1answer
25 views

Complex query (subqueries, window functions) with sqlalchemy

I'm trying to write the following sql query with sqlalchemy ORM: SELECT * FROM (SELECT *, row_number() OVER(w) FROM (select distinct on (grandma_id, author_id) * from contents) as c WINDOW ...
0
votes
2answers
18 views

Stop SQLAlchemy from updating rows that have already been pulled from the database

I'm creating a simple notification system for a website. The user's notifications are pulled from the database, marked as seen if they haven't been already, and then displayed to the user. The ones ...
0
votes
1answer
17 views

dynamic query filter with SQLalchemy operators

I have a list : scope_list = ['prd1 rls1', ' prd1 rls1 rls3 rls2'] I would like to create a filter based on scope_list that in SQL would look like : (product=prd1 AND `release` in (rls1)) OR ...
0
votes
0answers
10 views

SQLAlchemy scoped session & connection error

I´m experiencing "server has gone away" errors with my current slqalchemy scoped session pattern (MySQL backbone). Although I set a pool recycle option, the session disconnects, even in interactive ...

1 2 3 4 5 76
15 30 50 per page