Tagged Questions
0
votes
1answer
11 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
0answers
7 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
13 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
1answer
30 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
11 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
13 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
29 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
18 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
32 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
0answers
33 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
13 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. ...
0
votes
1answer
20 views
convert sqlalchemy query result to a list of dicts
I want to have the result of my query converted to a list of dicts like this :
result_dict = [{'category': 'failure', 'week': '1209', 'stat': 'tdc_ok', 'severityDue': '2_critic'}, {'category': ...
1
vote
2answers
34 views
Create dictionary of a sqlalchemy query object in Pyramid
I am new to Python and Pyramid. In a test application I am using to learn more about Pyramid, I want to query a database and create a dictionary based on the results of a sqlalchemy query object and ...
1
vote
1answer
32 views
sqlalchemy generic foreign key (like in django ORM)
Does sqlalchemy have something like django's GenericForeignKey? And is it right to use generic foreign fields.
My problem is: I have several models (for example, Post, Project, Vacancy, nothing ...
0
votes
2answers
59 views
Set SQLAlchemy to use PostgreSQL SERIAL for identity generation
Background:
The application I am currently developing is in transition from SQLite3 to PostgreSQL. All the data has been successfully migrated, using the .dump from the current database, changing all ...
1
vote
2answers
32 views
Select through multiple many to many relationships via SQLAlchemy
I want to be able to query through multiple many to many relationships in SQLAlchemy.
I have Users, which are associated to Groups, which are associated to Roles. All associations are many-to-many. I ...
0
votes
1answer
27 views
SQLAlchemy Generic Relationship simple example
I know similar questions have been asked, however I am really struggling to understand how generic fields are implemented in SQLAlchemy.
I have a Permissions class/table which I want to contain a ...
2
votes
1answer
23 views
SQLAlchemy DateTime to datetime.datetime
How do you make comparisons between DateTime fields and datetime.datetime objects in SQLAlchemy queries?
For instance, if I do
candidates = session.query(User).filter_by((User.time - ...
1
vote
2answers
19 views
sqlalchemy AND operator from dict
I am getting this weird behavior
test_dict = {'productDue' : ['foo'],'releaseDue' : ['bar']}
for attr, value in test_dict.items() :
print attr
and_args = ...
0
votes
0answers
17 views
Waiting for db will be available in sqlachemy
The task is to make a client for db which waits and tries to establish connection in case database is shut down or host with db is not available.
I've looked at documentation and see that one way to ...
3
votes
1answer
34 views
Flask SQLAlchemy - Need Help Mapping 3 Classes together
So I've spent some time on this and keep running around in circles and getting nowhere so I figured I'd come to the experts!
Using Flask 0.9 and SQLAlchemy 0.7.9 I'm attempting to create a Gallery ...
0
votes
0answers
12 views
SQLAlchemy TIMEDIFF in SQLite with Core
This query below works with MySQL, but since SQLite doesn't have a timediff function, I have to implement it myself. I am using a SQLite test database for unit tests, so I don't want to change my ...
0
votes
1answer
12 views
Overriding SQLAlchemy Columns for Testing
I'm trying to override a SQLAlchemy column to have different attributes in my test DB. Basically, I have a composite primary key in all of my MySQL tables: an autoncrement BIGINT id and a DATETIME ...
1
vote
1answer
26 views
Python, SQLAlchemy, how to insert queries in an efficient way with only one commit instruction
I am working with SQLAlchemy and my insert function works correctly. However, i want and i need it to be efficient, therefore since i am inserting inside a "for loop", i would like to commit just once ...
2
votes
2answers
61 views
How to build a flask application around an already existing database?
I already have an existing Database that has a lot of tables and a lot of data in MySQL. I intend to create a flask app and use sqlalchemy along with it. Now I asked out on irc and looked around on ...
0
votes
2answers
28 views
Delete rows without a related record using SQLAlchemy
I have 2 tables; we'll call them table1 and table2. table2 has a foreign key to table1. I need to delete the rows in table1 that have zero child records in table2. The SQL to do this is pretty ...
1
vote
1answer
34 views
SQLAlchemy multi-table joins
I'm trying to do the following join in SQLAlchemy
select * from splits s
join transactions t on t.guid = s.tx_guid
join accounts a on a.guid = s.account_guid
left join splits s2 on s2.tx_guid = ...
2
votes
3answers
45 views
Query to find missing weeks in timesheet
I am new to flask and ORM, and I am writing a sample application for my learning.
I have this model:
class Timesheet(Base):
__tablename__ = 'Timesheet'
id = Column(Integer, ...
0
votes
0answers
14 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 ...
0
votes
0answers
21 views
how to insert data into a table from another table in sqlalchemy?
I am writing a flask+python application in which i have used SqlAlchemy for database. I have a table song in which data is stored, its models is:
class song(db.Model):
__tablename__ = 'song'
...