Tagged Questions
0
votes
0answers
9 views
How can I check for the existence of an event listener in SQLAlchemy?
I'm implementing versioning in my SQLAlchemy mapped classes, following the example code here.
Here's the versioned_session function, which I call on each session I create:
def ...
0
votes
0answers
41 views
Why is this column becoming NULL when I simply print it?
I have a table with a primary key of 'pk'. I am using SQLAlchemy's merge to update a row in my table:
my_obj = MyTable()
my_obj.pk = 1234
#print my_obj.col1
DBSession.merge(my_obj)
...
0
votes
2answers
36 views
Python Pyramid : Delete, edit, and search in a table
My teacher gave us a project to create a program to manage a database with pyramid. We already did that with Python, but now we have to do it with Pyramid, everything has to be controlled by the ...
1
vote
1answer
42 views
unable to create autoincrementing primary key with flask-sqlalchemy
I want my model's primary key to be an autoincrementing integer. Here is how my model looks like
class Region(db.Model):
__tablename__ = 'regions'
id = db.Column(db.Integer, primary_key=True, ...
1
vote
1answer
14 views
Defining Indexes in SqlAlchemy with Alembic
I completely agree that this is a pretty basic question and may be it has its answer somewhere, but I somehow can not find it out. (also I am not very proficient with SqlAlchemy)
I have this code --
...
0
votes
2answers
21 views
ImportError : from sqlalchemy.databases.sqlite import DateTimeMixin
I am trying to import the DateTimeMixIn from sqlalchemy.databases.sqlite
from sqlalchemy.databases.sqlite import DateTimeMixin
ImportError: No module named sqlite
My sqlalchemy version is 0.8.4
If ...
0
votes
0answers
19 views
Confused with SQL LIMIT and OFFSET in sqlalchemy
everyone.I got some problems while I was using FLask and SQLAlchemy.
I have there models:
tag_article_table = db.Table('tag_article_table',
db.Column('article_id', db.Integer, ...
0
votes
2answers
15 views
How to avoid inserting duplicate entries when adding values via a sqlalchemy relationship?
Let's assume we have two tables in a many to many relationship as shown below:
class User(db.Model):
__tablename__ = 'user'
uid = db.Column(db.String(80), primary_key=True)
languages = ...
1
vote
1answer
48 views
Unable to create self referencing foreign key in flask-sqlalchemy
I have a model Region and each Region can have sub-regions. Each sub-region has a field parent_id which is the id of its parent region. Here is how my model looks like
class Region(db.Model):
...
2
votes
1answer
39 views
SQLAlchemy: Knowing the field names and values of a model object?
I'm trying to keep to SOLID object oriented programming principles, stay DRY, etc, but Python/SQLAlchemy/Pyramid is making it very hard.
I'm trying to take what I now know to be a SQLAlchemy model ...
0
votes
2answers
38 views
sqlalchemy apache mod_wsgi crash with pyramid
I am running a basic Pyramid application with apache mod_Wsgi. My application setup seems Ok since I can access the home Pyramid template under Apache.
As soon as I issue a request to this app, the ...
0
votes
1answer
27 views
How to get a list from query in sqlalchemy
when I do the following in python using sqlalchemy
someVar = self.session.query(sometable.someVar).group_by(sometable.someVar).all()
I get a list of one variable tuples like
[(var1,), (var2,), ..]
...
3
votes
1answer
30 views
How do I ensure tearDown is called (in the case of an uncaught exception in the test) with nosetests?
I have a test-case with both a setUp and tearDown method:
TESTCONF = SafeConfigParser(...)
ENGINE = create_engine(TESTCONF.get('database', 'dsn'))
class TestBase(TestCase):
def setUp(self):
...
0
votes
1answer
28 views
+100
Geoalchemy2 query all users within X meteres
I have an app that takes an address string, sends it to Google Maps API and gets lat/long co-ordinates, I then want to show the all users within X meteres of this point (there lat/long is stored in my ...
0
votes
0answers
20 views
MySQL fix badly inserted characters
I inserted some data into my database using SQLAlchemy, when the data gets printed in the shell it looks OK, the problem arises when I look for the data in the database. To the chase, my table was ...
1
vote
3answers
37 views
Using a different schema for the same declarative Base in sqlalchemy
I am new to both Pyramid and SQLAlchemy. I am working on a Python Pyramid project with SQLAlchemy. I have a simple model set up below. How would I go about being able to use this with different ...
0
votes
1answer
53 views
Self-referential class: How to get jerarchical structure of employees in a company?
I have a class defined in Python called Employees. Its attribute id_supervisor is the id of the employee who is in charge of him.
One employee can be in charge of (supervise) many other employees.
...
0
votes
0answers
23 views
PostgreSQL Update with SQLAlchemy ORM not working [duplicate]
I'm performing an update on a row in a PostgreSQL db via SQLAlchemy ORM in Python using the following:
def update_func(session, db, record, *args, **kwargs):
query = ...
1
vote
1answer
16 views
Can I create a SQLALCHEMY model from the pure sql CREATE?
I am checking SQLAlchemy and it's models and I was wondering if having the raw CREATE sql from a database, I can create the models automatically or do I have to create them by hand class per class?
...
0
votes
0answers
23 views
Is it possible for the codecs.open function to be inconsistent?
I have several files which are supposed to be ASCII encoded but they sometimes aren't. As such, am parsing through the files and those that throw a UnicodeDecodeError I skip.
However, I've noticed ...
1
vote
0answers
10 views
Prevent SQLAlchemy from changing fields on associations with two-column foreign keys
I'm using SQLAlchemy 0.8.4 with PostgreSQL 9.2.
I've got three simple models: Account, Address, and CreditCard. Both Address and CreditCard have a required Account association. Address has an ...
0
votes
1answer
40 views
SQLAlchemy create_all() does not create tables
I'm trying to integrate PostgreSQL and SQLAlchemy but SQLAlchemy.create_all() is not creating any tables from my models.
My code:
from flask import Flask
from flask.ext.sqlalchemy import ...
0
votes
0answers
31 views
SQLAlchemy execute() return ResultProxy as Tuple, not dict
I have the following code:
query = """
SELECT Coalesce((SELECT sp.param_value
FROM sites_params sp
WHERE sp.param_name = 'ci'
AND ...
0
votes
0answers
32 views
How to load a table along with its dependencies fkey columns using SQL Alchemy?
I need to export data from one DB to another instance / deployment ( eg: testing to production ) (same vendor/schema) . Can I achieve this using SQL Alchemy ? Its for a simple Import Export ...
1
vote
1answer
46 views
Validation in SQLAlchemy
How can I get the required validator in SQLAlchemy? Actually I just wanna be confident the user filled all required field in a form. I use PostgreSQL, but it doesn't make sense, since the tables ...
1
vote
1answer
18 views
Why do SQLAlchemy classes inheriting from Base not need a constructor?
With SQLAlchemy objects inheriting from the Base class I can pass arguments to a class for variables which aren't defined in a constructor:
from sqlalchemy.ext.declarative import declarative_base
...
0
votes
0answers
20 views
load class when there is no engine [sqlalchemy]
I declared a class like
Base = declarative_base()
class ContractSla(Base):
__tablename__ = Table('contract_sla', metadata, autoload=True)
I want to automatically assign all attributes from ...
0
votes
1answer
39 views
Python Real-time Busy Polling a Database
I have a database table that gets row/record INSERTS from a third-party application. This table has one column labeled 'active' that is always False when each new record is INSERTED by the third-party ...
0
votes
1answer
33 views
How to write select statement in sqlachemy
I want to do the select statement in sqlachemy like
select user.id from user where user.name = 'test'
I loaded user table by:
User = Table('user',metadata,autoload=True)
Result = ...
1
vote
1answer
27 views
How to pass the name of a column as a parameter in SQLAlchemy Core?
I have an sqlalchemy core bulk update query that I need to programmatically pass the name of the column that is to be updated.
The function looks as below with comments on each variable:
def ...
1
vote
1answer
22 views
sqlalchemy: Controlling columns selected from query
I'm having a bit of an issue with sqlalchemy. I'm creating a query like:
db.session.query(Case.court_id).filter(
Case.last_updated.between(start, end)).filter(
...
0
votes
0answers
12 views
Using wtforms-alchemy, can I use a “default” validator for all fields?
I'm currently playing with wtforms-alchemy and I'd like to create a form that has a BooleanField "remove_checkbox", that, when True, should cause the validation for all other fields to pass.
So with ...
0
votes
1answer
45 views
Strange AttributeError in Flask based website
I am developing a website based on Flask and SQLAlchemy
ssis created by sessionmaker in sqlalchemy.orm
Anime, ActorQuote, AnimeComment are models based on database structure
```
...
0
votes
1answer
38 views
SQLAlchemy update PostgreSQL array using merge not work
I'm using SQLAlchemy to access PostgreSQL database, and I defined the object like this:
class SessionLog(Base):
__tablename__ = 'session_log'
id = Column(Integer, primary_key=True)
...
0
votes
1answer
38 views
How to speed up bulk update in postgresql
Got a script that was running very fast (about 20 seconds to process 30,000 records) when I am processing 100,000 records or thereabouts. The scripts grabs records from a postgresql database, ...
0
votes
1answer
21 views
Camelot (Python framework): Specifying an Alternative EntityAdmin
With the Camelot framework, models (subclassed from Entity) are defined with a nested class (subclasses from EntityAdmin) that defines various gui properties like layout and other widgets. The ...
0
votes
1answer
35 views
How do I convert a multiprocessor.manager.list to a pure python list
I have my normal script doing about 30,000 records in 20 seconds. Given that amount of data that I have to run through (over 50 million records), I thought it wise to use python's multiprocessing.
At ...
2
votes
0answers
33 views
How to use USING clause in Alembic/SQLAchemy?
I would like to change column type of the database from string to integer by using Alembic. If I use pure SQL, it achieves the goal:
alter table statistic_ticket alter column tags type bigint using ...
0
votes
0answers
62 views
Python/SQLAlchemy - Need to delete all the records(from one of the two tables)returned from an inner join query
I'm using Postgres 9.2 and I need some help converting this query to Python.This query works just fine when run manually.Appreciate any help with this.
The query and the tables are in this fpaste.
...
1
vote
1answer
36 views
Convert SQL to SQLAlchemy
I got this native SQL query that does what I want:
SELECT id, formula FROM (
SELECT formula_id
FROM formula_quantity
INNER JOIN quantities ON quantities.id
WHERE quantity in ('v', 't', 'x')
...
0
votes
1answer
28 views
How to create ENUM in SQLAlchemy?
from sqlalchemy import *
from migrate import *
meta = MetaData()
race_enums = ('asian','mideastern','black','nativeamerican','indian','pacific','hispanic','white','other');
profiles_profiles = Table(
...
1
vote
0answers
28 views
How to use the ORM when multiple sqlite 'documents' can be opened
In an application that uses sqlite files as documents in a new, open, save, and close type fashion what would be the appropriate way to configure the engines so that I could use the ORM?
from ...
2
votes
0answers
43 views
How to create viewonly field in SqlAlchemy and GeoAlchemy2?
I am trying to dynamically populate a field using SqlAlchemy 0.8.4 and GeoAlchemy2 0.2.2. The goal is to assign a District to the Facility based on the facility's position when it is read from the ...
0
votes
1answer
26 views
SQLAlchemy Flask, match some or all
I have a list of schools (1000's) with a name, city, and state.
There are name, city and state input fields.
I want to search for schools by name. If they leave city or state inputs empty I want to ...
0
votes
0answers
20 views
sqlalchemy + postgresql + COPY command not behaving
I am using the COPY command in sqlalchemy and it's not working when a lot of data is copied. Here is the output when I have echo='debug' set:
$ python parse.py
2013-12-16 16:00:20,128 INFO ...
1
vote
1answer
23 views
Saving and restoring queries in flask-SQLAlchemy
I'm building queries based on searches done by the user, but only extracting slices. Within the next 10 minutes, the user may request the next slice\page, so I'd like to store the query and restore it ...
0
votes
1answer
32 views
What is the right way to test a SQLAlchemy dialect?
I implement my own SQLAlchemy dialect for a RDBMS.
What is the best way to test the dialect, I've implemented?
Are there any automated test suites, that could help me?
What is the best way to make ...
0
votes
1answer
22 views
Python adding utility functions to SqlAlchemy Entity classes
In my Python package, I have defined a number Sqlalchemy Entity classes. All classes are defined using ORM declarative techniques. Most classes map directly to database tables (in a 1:1 fashion) using ...
1
vote
1answer
28 views
cx_freeze not seeing sqlalchemy under windows?
I'm using Python 3.2 32bit with sqlalchemy installed. I have written quite simple script in Python using sqlalchemy. I'm importing it like that:
from sqlalchemy import *
from sqlalchemy.orm import ...
0
votes
1answer
99 views
Sqlalchemy, python, easiest way to populate database with data [closed]
I tend to start projects that are far beyond what I am capable of doing, bad habit or a good way to force myself to learn, I don't know. Anyway, this project uses a postgresql database, python and ...