Tagged Questions
2
votes
2answers
27 views
Sqlalchemy commit changes to object (modified using its dictionary)
I am developing a multiplayer game. When I use an object from inventory, it should update the user creature's stats with the values of the attributes of an object.
This is my code:
try:
obj = ...
0
votes
1answer
17 views
Why do Sqlalchemy Session.close not log “rollback”?
# I've set echo=True when doing create_engine, so I can see all the sql stmt
# DBSession is ScopeSession(thread_local) and autocommit is False
session = DBSession()
session.add(somemodel)
#
try:
...
1
vote
1answer
22 views
SQLAlchemy PostgreSQL Pyramid update issue
I have the following model:
class Employee (Base):
__tablename__ = 'employees'
id = Column(Integer, primary_key=True, autoincrement=True)
name = Column(String(300), ...
0
votes
1answer
19 views
sqlalchemy multiple foreign keys to same table
I have a postgres database that looks something like this:
Table "public.entities"
Column | Type | Modifiers
...
0
votes
2answers
19 views
How to update a relationship when another field is modified in SQLAlchemy
I have a simple Client model in SQLAlchemy, using mostly declarative. This model has a name field and has a many-to-many relationship with a MetaphoneCode model. The code goes like this:
class ...
0
votes
1answer
23 views
Sqlalchemy order by calculated column
I'm trying to build a select query using sqlalchemy, but I need to sort the results by a calculated value and I'm not sure how to do it.
Basically, I have a 'start_time' and 'end_time' columns and I ...
0
votes
1answer
35 views
Combining PostgreSQL Enum with a TypeDecorator
Is there a way to have an Enum class that will both get created automatically when creating a new DB, like the standard Enum, but also connect it to a TypeDecorator that runs process_bind_param?
This ...
0
votes
2answers
57 views
Python, Flask + SQLAlchemy - query not working
I've got the following Python code
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql+psycopg2://my_user_name:@localhost:5432/my_db'
db = SQLAlchemy(app)
...
1
vote
1answer
16 views
sqlalchemy nested inheritance / polymorphic relationships
I have a tree that looks like this, reflected via polymorphic inheritance:
A
/ | \
B C D
That works great, like:
class BaseModel(db.Model): # Table A in diagram
...
1
vote
1answer
25 views
SQLAlchemy, eager loading on object refresh
If have following ORM setup in SQLAlchemy:
class Foo(Base):
id = Column(Integer, primary_key=True)
status = Column(String)
barId = Column(Integer, ForeignKey("bar.id"))
bar = ...
0
votes
1answer
17 views
SQLAlchemy complex many to many with abstractions
We have this pattern in our very complex database which essentially boils down to a directed graph with metadata on each edge. We're solving it, but I'm sure there is a "better" solution. I'm going to ...
1
vote
0answers
33 views
MySQL (mariaDB) Connection Error with SqlAlchemy
Hello I have a mariaDB database on a Ubuntu server running in a virtual box.
With 'Sequal Pro' i can connect without any problems (with the ssh option).
Port forwarding like this: HOST 127.0.0.1 3306 ...
1
vote
0answers
14 views
sqlalchemy literal text added to an insert
I'm trying to get sqlalchemy to accept some more complex behavior on an insert, and can't figure out the idiomatic way to do it. To simplify things, I was just trying to add a literal string to the ...
2
votes
0answers
22 views
Camelot for Desktop Application
I am developing a GUI application in Python and have already used SQLAlchemy for database interactions. I was going to use PyQt for the GUI development and then came across the framework Camelot. I ...
0
votes
0answers
25 views
SQLAlchemy and selecting on datetime column
I have declared a table using SQLalchemy like so:
Database.engine = create_engine('sqlite:///file.db', echo=True)
Database.metadata = MetaData()
Database.metadata.bind = ...
1
vote
2answers
68 views
UnboundExecutionError from SQLAlchemy in Cherrypy project using Nginx with uWsgi
I am currently using SQLAlchemy as ORM in my Cherrypy project. The error that I have does not occur while I am on my cherrypy enbedded webserver, but ONLY from my Nginx deployment.
On Debian Wheezy ...
6
votes
1answer
73 views
Find out what's going to be deleted
When using more complex, hierarchical models with differing settings on how cascade deletes are handled it gets quite hard to figure out beforehand what a delete() will exactly do with the database.
...
1
vote
1answer
74 views
Oracle database schema using SQLAlchemy
I have a problem with SqlAlchemy. When I define the schema in my Oracle database, foreign keys are not recognized in other tables. Tested without using layout and it worked. But I need to define the ...
1
vote
1answer
21 views
How to dynamically create classes inside a module-level initialize() method in Python
I'm writing a library to talk to a database using SQLAlchemy. I really like SQLAlchemy's autoload_with=engine feature, which can be passed to the Table constructor to grab all of the table's columns ...
0
votes
1answer
18 views
Issue with multiple sessions
In my application I'm using SQLAlchemy for storing most persistent data across app restarts. For this I have a db package containing my mapper classes (like Tag, Group etc.) and a support class ...
3
votes
1answer
21 views
Is there a way to perform a join across multiple sessions in sqlalchemy?
If I have multiple sessions to different databases, is there a way to perform a join across them in one query?
For instance, I'm integrating two programs, with a table in the middle to translate id's ...
0
votes
0answers
22 views
Alembic detects changes but produces empty migration with --autogenerate
I'm trying to get alembic working auto-producing migrations with the --autogenerate flag.
When I run alembic -n mydbname --autogenerate -m "my message" I get something like:
INFO ...
0
votes
1answer
40 views
Error flask-sqlalchemy NameError: global name 'joinedload' is not defined
I'm trying to use a sqlalchemy loading strategy to speed up my queries. After reading this I realized that I was making the mistake of looping through the records in my template. The only problem is ...
0
votes
2answers
31 views
SQLAlchemy variable relationship
I'm unclear on how to configure SQLAlchemy for the following scenario:
Several tables of varying nature.
All tables need to reference a one-to-many notes table
Would like to only have one notes ...
0
votes
0answers
20 views
sqlalchemy undefined Table
Not sure why, but I get
NameError: name 'Table' is not defined
with the following code. Anyone have any idea?
from sqlalchemy import create_engine, MetaData
class Boo:
engine = ...
0
votes
0answers
32 views
Debianize SQLAlchemy using python-stdeb & dpkg
I am trying to build a .deb package for sqlalchemy, using the python stdeb builder.
Respecting the python stdeb usage I use the following instructions:
wget ...
3
votes
1answer
43 views
Override the __eq__ operator in sqlalchemy
I'm working with declarative base SQLAlchemy. I'm in need of a string column that can be nulled but not have the NULL != NULL problem that comes along with databases. So I've written a custom ...
1
vote
1answer
56 views
sqlalchemy bulk update performance problems
I need to increment values in a column periodically with data I receive in a file. The table has > 400000 rows. So far, all my attempts result in very poor performance.
I have written an experiment ...
0
votes
1answer
43 views
should SQLAlchemy session.begin_nested() be committed with transaction.commit() when using pyramid_tm?
I'm developing a pyramid application and currently in the process of moving from sqlite to postgresql. I've found postgresql more restrictive transaction management is giving me a bad time.
I am ...
0
votes
2answers
26 views
sqlalchemy does not enforce foreign key constraing
I am trying to play with the sql alchemy ORM based db definition.
I have defined my tables as follows
class Customer(Base):
__tablename__ = 'customer'
id = Column(Integer, ...
1
vote
0answers
41 views
Where are the python-native objects for SQL-Alchemy?
In an ORM I would expect to be able to do this:
session.add(Lake("hello",Polygon([(0,0),(1,0),(1,1)])))
lake = session.get(Lake).first()
assert isinstance(lake.geometry, Polygon)
assert ...
0
votes
2answers
55 views
py2exe [ImportError: No module named sqlalchemy]
I installed sqlalchemy-0.8.1 in my win7 via 'setup.py install'
and "import sqlalchemy" works well
But when I want to pack my files with py2exe, error occurs
ImportError: No module named sqlalchemy
...
-2
votes
0answers
20 views
postgresql.CIDR and sqlalchemy [closed]
SELECT net FROM nets WHERE net >> '10.0.0.0/8'
How to convert this sql-code to sqlalchemy? 'net' has type CIDR in postgres. Is it possible?
0
votes
1answer
29 views
Retrieve distinct backref instances from SQLAlchemy query
Given the following models:
class Foo(db.model):
id = db.Column(db.Integer, primary_key=True)
bar_id = db.Column(
"bar_id",
db.Integer(),
db.ForeignKey("bar.id"))
...
1
vote
1answer
62 views
Populate a WTForms form object with a datetime.date
I'm cooking up a crud interface for an object representing a bill, as in the water bill, the electric bill, etc.
I'm using sqlalchemy to handle the data, wtforms to handle the forms, and flask to ...
0
votes
1answer
35 views
SQLAlchemy MySQL STRAIGHT_JOIN
My code currently executes queries just fine in the SQLAlchemy ORM layer like so:
session().query(model_a).join(
(model_b, something == somethingelse)
).join(
(model_c, something == ...
0
votes
0answers
20 views
Select name by id in another table
I have the tables Articles(id, name(text), category(int), text(text)) and Categories(id, name(text))
query
db_session.query(Articles).all()
How I can with ORM select All from Articles with replacing ...
0
votes
0answers
22 views
How to have more than one tables backref a table with the same property name
So I wanted to achieve, which when described in plain words, would be something like:
The parent model class is able to return all the instances of models where it is ForeignKeyed, under a single ...
0
votes
1answer
17 views
SQLalchemy hierarchical hybrid-transformation
BASED on http://docs.sqlalchemy.org/ru/latest/orm/extensions/hybrid.html#hybrid-transformers
Hello fellow sqlalchemy coders!
I have a data of the form:
from sqlalchemy import Column, Integer, ...
4
votes
1answer
28 views
SQLAlchemy : is there any good automated way to rename columns
I'm using SQLAlchemy ORM for a few days and i'm looking for a way to get tablename prefix in the results of Session.query().
For instance :
myId = 4
...
data = ...
2
votes
2answers
26 views
sqlalchemy: How do I enforce date range on column?
Here is how my column looks
financial_day_of_month = Column('financial_day_of_month', Integer,
nullable=False, default=1)
I want to enforce that min=1 and max=31 ...
0
votes
1answer
28 views
Flask-SQLAlchemy TimeoutError
My backend configuration is :
Ubuntu 12.04
Python 2.7
Flask 0.9
Flask-SQLAlchemy
Postgres 9.2
I've got this error message:
TimeoutError: QueuePool limit of size 5 overflow 10 reached, ...
0
votes
1answer
49 views
Many-to-many relations from table to itself in SQLAlchemy
I'm using SQLAlchemy to represent a relationship between authors. I'd like to have authors related to other authors (coauthorshp), with extra data in the relation, such that with an author a I can ...
0
votes
0answers
37 views
Celery task hangs when chaining to a group
I'm trying to write a celery workflow that syncs a set of contacts from a remote system to the local database. I would like to split the results of the remote system api call into several batches, so ...
0
votes
1answer
29 views
Doing threading with sqlalchemy properly?
I have a multi threaded application where the treads work on some objects fetched using sqlalchemy. The objects are put in a thread queue which the threads poll from.
In the main thread I am doing ...
0
votes
0answers
22 views
SQLAlchemy Declarative Bi-Directional Association: append and value set at once
GENERAL QUESTION
Is it possible to append an association and set a value(s) to be stored in association table in one command?
CODE
To do so, I'm working on one of more interesting examples of ...
-1
votes
1answer
36 views
Python and Oracle Views
Can someone give me brief information about how to "connect" to an Oracle view from Python?
I looked around but couldn't anything. I'm new to Oracle DB. I will not use it I will only connect it with ...
3
votes
2answers
42 views
How to locate a function in a Python module tree?
I'm using SQLAlchemy and am trying to import the function group_by into the interpreter, but I can't seem to find it. Is there an easy way to search the module tree to see where this function lives?
...
0
votes
2answers
49 views
Flask how to calculate tags count
I developing simple blog with tagging support. Actually I would like to add tags cloud functionality and I need to get count of each tag used in blog.
My Blog and Tag models looks like:
class ...
0
votes
0answers
52 views
Sqlalchemy based alternatve to Django [closed]
Hi I have been using Django to a reasonably advanced level over the last two years. I think it is great for most things, but I notice that the ORM is somewhat limited for some of the tasks I want to ...