2
votes
2answers
15 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
17 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
14 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
15 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
41 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
69 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
28 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
51 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
43 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
20 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
19 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
1answer
62 views

PIL โ”€ Python Imaging Library โ”€ Uploading image thumbnail to SQLAlchemy database via CherryPy

# ! /usr/bin/env python # -*- coding: utf-8 -*- # image_upload.py """ Python 2.7.3 Cherrypy 3.2.2 PostgreSQL 9.1 psycopy2 2.4.5 SQLAlchemy 0.7.10 PIL ...
4
votes
1answer
94 views

Improve query performance

I need to read and join a lot of rows (~500k) from a PostgreSQL database and write them into a MySQL database. My naive approach looks like this entrys = Entry.query.yield_per(500) for ...
0
votes
1answer
28 views

Composite Foreign Key in SQLAlchemey allowing references to non-existent records

I have a database with a concept of points and objects. Objects are associated with a single point in a one-to-one relationship. Only 1 object can be associated with a point at a time, which I have ...
0
votes
1answer
15 views

sqlalchemy cannot drop table

I create my table use next code: class tableName(self._dbHelper.DeclarativeBase): __tablename__ = "tableName" if not tableEngine is None: ...
0
votes
0answers
17 views

sqlalchemy close all connection

I'm trying to drop my database using sqlalchemy: I use next: def dropDb(self, dbName): self.closeConnection() self.selectDb(None) self.execute("drop database %s" % dbName) def ...
1
vote
1answer
44 views

SQLAlchemy convert outer join ORM query to Core

I'm having problems with SQLAlchemy's select_from statement when using the core component. I try to construct an outer join query which currently looks like: query = select([b1.c.id, b1.c.num, ...
0
votes
1answer
24 views

SQLAlchemy add columns to query() on mapped class

I'm wanting to do pagination, I'm using PostgreSQL. To avoid doing the query twice, I'm using the feature described at http://stackoverflow.com/a/8242764 How can I add the full_count column to the ...
1
vote
2answers
45 views

How to execute raw SQL in SQLAlchemy-flask app

I have inherited a python web app that runs on flask and interfaces to the database through SQLAlchemy. I know little about SQLAlchemy and I need to run an update query after uploading a CSV file. ...
0
votes
1answer
47 views

This Non-Threaded script unexpectedly runs faster than the Threaded version

I have a python script which validates data fetched from some rows in a database and then logs the errors in a different table in the same database. The script validates each row and marks it as ...
0
votes
0answers
16 views

Deciding schema for site with articles with editable tags?

I am making a blog like application and I need to have articles which have tags that are editable and deletion of tags will reflect change in the articles too. I am using Flask-SQLAlchemy and ...
0
votes
1answer
11 views

add row to declarated table sqlalchemy

How can I add row to my table in database, use the sqlalchemy? I use next code: for i in range(count): name = Utils.uniqID() class name(Base): __tablename__ = name ...
2
votes
1answer
39 views

In Flask-SQLAlchemy, where do I initialise and store the database object?

I am building a website using Flask and SQLAlchemy in Python, and having great fun so far. There is something I'm not sure about, however. The following code is used to connect to the database: app ...
1
vote
1answer
28 views

sqlalchemy connect to server, with not specify database

Is it possible to connect to MSSQL server, using sqlalchemy and thencreate a database? I use the following: sqlalchemy.create_engine("mssql+pyodbc://sa:pwd@localhost/") But I get an error: Detail ...
1
vote
1answer
24 views

Reference query results with outerjoin in Flask/SQLAlchemy/jinja

I have the following query: last_entry = Table.query \ .group_by(Table.email) \ .order_by(Table.date) \ .subquery() results = ...
0
votes
0answers
27 views

SQLAlchemy Inheritance not working with Postrgres

My Postgres database does not reflect the SQLAlchemy inheritance in my models.py file. The database only recognizes SportTeam, SoccerTeam and BasketballTeam are not in the database. In PGAdmin, the ...
2
votes
1answer
38 views

how to clean up incomplete alembic run

I'm trying to use alembic with a MySQL engine to perform online migrations. I've found that when an operation in my onupgrade() method fails my database gets stuck in an inconsistent state and i ...
1
vote
2answers
37 views

SQLAlchemy Query Possible?

This code doesn't work. Is there a way to make something like this happen in SQLAlchemy? In the below there is a table named "Game_Table" and it has a column called "name". list_of_games = ...
0
votes
1answer
30 views

Doing DateTime Comparisons in Filter SQLAlchemy

I'm a bit confused about filtering in SQLAlchemy. I currently am trying to filter out entries greater than 10 weeks, so I have current_time = datetime.datetime.utcnow() potential = ...
1
vote
1answer
32 views

Does a one-to-one Relationship Mean Unnecessary Tables When Designing An SQL Database? [closed]

My question is more conceptual than anything else. I'm designing the schema for a database that I am about to create using SQLAlchemy (a python toolkit for sql databases, http://www.sqlalchemy.org/), ...
0
votes
1answer
27 views

Inheriting AbstractConcreteBase multiple times [was: Adding an Auto-ID field to a model base class via mixin]

I have created an ModelBase class for an application of mine based on SQLAlchemy. To save me the tedious work of having to type out id = Column(Integer, primary_key=True) I provided the attribute as ...
2
votes
0answers
32 views

Store Connection Parameters for SQLAlchemy securely

I'm writing an application in Python 2.7 + SQLAlchemy that will need to access hundreds of PostgreSQL databases, each on its own server. To connect using SQLAlchemy, an engine is created by passing ...
3
votes
3answers
63 views

using flask-sqlalchemy without the subclassed declarative base

I am using Flask for my python wsgi server, and sqlalchemy for all my database access. I think I would like to use the Flask-Sqlalchemy extension in my application, but I do not want to use the ...
0
votes
1answer
23 views

alembic will allow sql files under versions?

In sqlalchemy-migrate repos, we can place .sql files instead of .py files under versions folder for upgrading/downgrading database schema. 001_mysql_downgrade.sql 001_mysql_upgrade.sql Is the same ...
0
votes
0answers
37 views

SQLAlchemy custom field with default value for file uploads in Flask

I'm trying to create a custom field in SQLAlchemy for managing uploaded files in a Flask application. I'm basically trying to achieve something similar to Django's FileField. So what I want to be ...
3
votes
3answers
70 views

SQLAlchemy Filtering Not Working

I have been trying to use a filter on a query, but for some reason the filtering does not seem to be working. For example, if I run the command: Curriculum_Version.query.filter(Course.course_code == ...
1
vote
2answers
50 views

Insert MySQL timestamp column value with SqlAlchemy

I have a sqlalchemy class mapping to a database table in MySQL innoDB. The table has several columns and I am able to successfully populate them all except from a TIMESTAMP column: The mapping: ...
0
votes
1answer
24 views

Connecting to locally postgresql using sqlalchemy

Definitely a beginner here. I'm having issues connecting to postgresql database run locally on a macosx machine using postgres.app and sqlalchmey: import psycopg2 import sqlalchemy engine = ...
0
votes
0answers
16 views

Python Sqlite3 SQLAlchmey - Order Desc Slow

I built a DB using sqlite3 and sqlalchemy. Inside of a declarative class for a table - called Game - I put this definition in def game_history(self, s, side, quantity): if side == "dog": ...
2
votes
2answers
42 views

Flask-SQLAlchemy join across 3 models and a Table construct

I have 3 models: class Customer(Model): __tablename__ = 'customer' id = Column(Integer, primary_key=True) statemented_branch_id = Column(Integer, ForeignKey('branch')) ... class ...
0
votes
1answer
20 views

how to get backref name in sqlalchemy?

class User(Base): __tablename__ = 'users' addresses = relationship('Address', order_by='Address.id', backref='user') class Address(Base): __tablename__ = 'addresses' user_id = ...
0
votes
1answer
17 views

Argument error in SQLalchemy

This is my first time using SQLalchemy. I have created a Newsletter class/table: class Newsletter(Base): __tablename__ = 'newsletter' email = Column(String(255), primary_key=True) ...
1
vote
2answers
47 views

testing flask sql alchemy

I have a working web application on Flask with SqlAlchemy for moderation of news, it has some api methods to handle moderation requests, such as approve, deny currently selected news, list them, etc. ...
1
vote
0answers
19 views

Transfer Beaker Memcache into SqlAlchemy (MySQL)

I work with Flask and want to create some user sessions working on database. Thanks to some help I found this snippet http://flask.pocoo.org/snippets/61/ from flask import Flask, request from ...
0
votes
1answer
19 views

SqlAlchemy connection string [duplicate]

I faced very strange issue - my solution using sqlalchemy cannot connects to database. It depends on password I am using. for example, following records are working perfect: PWD='123123123' ...
2
votes
2answers
36 views

Target database is not up to date

I'd like to make a migration for a Flask app. I am using Alembic. However, I receive the following error. Target database is not up to date. Online, I read that it has something to do with this. ...
0
votes
1answer
30 views

sqlalchemy PK from raw SQL insert

I'm trying to get new entrie PK id from insert with raw SQL query with SQLalchemy like this https://gist.github.com/greggyNapalm/6045595 >>> sys.version '2.7.3 (default, Aug 1 2012, ...
1
vote
2answers
42 views

How to get inserted_primary_key from db.engine.connect().execute call

I'm using: CPython 2.7.3, Flask==0.10.1 Flask-SQLAlchemy==0.16 psycopg2==2.5.1 and postgresql-9.2 Trying to get PK from insert call with alchemy. Getting engine like so: app = Flask(__name__) ...
2
votes
1answer
57 views

How do I get rid of a circular dependency error while creating a database in sqlalchemy?

I'm new at using sqlalchemy. How do I get rid of a circular dependency error for the tables shown below. Basically my goal is to create A question table with a one to one relationship "best answer" to ...
1
vote
1answer
20 views

Generate Python Class and SQLAlchemy code from XSD to store XML on Postgres

I have some very complex XSD schemas to work with. By complex I mean that each of these XSD would correspont to about 20 classes / tables in a database, with each table having approximately 40 fields. ...

1 2 3 4 5 47
15 30 50 per page