Tagged Questions
1
vote
3answers
30 views
Celery Worker Database Connection Pooling
I am using Celery standalone (not within Django). I am planning to have one worker task type running on multiple physical machines. The task does the following
Accept an XML document.
Transform ...
0
votes
1answer
17 views
Django 1.4 syncdb + psycopg fails with Timezone Error
After installing Postgres.app on MacOS, and initialising a python virtualenv with Django, dj-database-url, and psycopg2 I repeatedly got:
...
2
votes
2answers
23 views
Push table data from django postgres model to remote oracle database
Hey guys i have a problem. There is an application that i built using django and it runs on postgresql. The application works perfectly but until recently , i was asked to push particular table data ...
0
votes
1answer
27 views
sqlalchemy FOR UPDATE NOWAIT
The documentation for sqlalchemy says that you can specify "FOR UPDATE NOWAIT" in PostgreSQL 8.1 upwards using Query.with_lockmode('update_nowait'). Does anyone know how to get it to add the FOR ...
5
votes
1answer
61 views
SQLAlchemy: limit in the same string as where
We're trying to enable a SQL query front-end to our Web application, which is WSGI and uses Python, with SQLAlchemy (core, not ORM) to query a PostgreSQL database. We have several data layer ...
0
votes
0answers
26 views
Push table data from django database to remote oracle database
Hey guys i have a problem. There is an application that i built using django and it runs on postgresql. The application works perfectly but until recently , i was asked to push particular table data ...
0
votes
1answer
44 views
Django custom management command error when executed via cron
I have a custom command that checks an email account and downloads and parses emails. The details about it are not relevant to this problem.
When I run this command from the shell, like:
cd ...
2
votes
1answer
61 views
Sqlalchemy complains that foreign key doesn't exist but actually it exists
I have the following models:
class Look(Base):
__tablename__ = "looks"
id = Column(Integer, primary_key=True)
url = Column(String, nullable=False, unique=True)
class Similarity(Base):
...
0
votes
0answers
27 views
heroku application crashes
While doing Flask with postgresql database, I experience a problem. My app can use the postgres database on the heroku, and the application is working well(when trying $foreman start). But when deploy ...
0
votes
1answer
63 views
Python not calling an external program part 2
I am having problems running a python program (plpython3u, really) as a trigger from postgres (9.2). The trigger calls the python program with the following statement:
perform scalesmyone(new.id);
...
1
vote
5answers
67 views
sql Like alternate
Is there any other solution available to use instead of Like to match starts with?
here is my query to match starts with using like.
explain analyze select * from completedcalls where call_id like ...
0
votes
1answer
31 views
Django DatabaseError - No such savepoint
I have a function the a Celery task calls in my Django app that processes each row in a CSV file and tries to insert information from each row into the PostgreSQL database using a model, like so:
...
1
vote
2answers
46 views
SQLAlchemy raises TypeError when an INSERT returns no rows?
I've got an insert statement like this:
insert = MyTable.insert()
row = {"foo": 42}
result = cxn.execute(insert, row)
But a Postgres trigger is redirecting inserts from mytable to a new table, so ...
2
votes
2answers
80 views
Python hangs during a cursor.execute() using Psycopg2
I currently have a problem with my Python script that when I execute a SQL function from cursor.execute() for a specific function, It runs the function, function completes, and then the script hangs ...
2
votes
1answer
46 views
How to use SQLAlchemy to select value at a position in a PostgreSQL ARRAY?
For a nested comment system, I am storing a tree structure in a PostgreSQL table using the following definition in the Comment model:
path = sa.Column(ARRAY(sa.Integer))
This stores all the IDs of ...
2
votes
2answers
51 views
Filter SQL statement against malicious injection in Python
Would like to allow a client application to execute SQL queries against our database.
The queries will be requests for data, the client should never be able to modify data.
Is there a way to allow a ...
0
votes
0answers
36 views
executing PL/PGSQL blocks using python without storing them into database
Am working to build Django application using python, the application is expected to receive large volume of data, I've worked on some PL/PGSQL procedures that can enhance the performance. Those ...
-1
votes
1answer
77 views
Python not calling external program
I am having problems with a python program that I wrote. It is actually plpython3u. I am running the program as a Trigger from postgres. I am pretty sure the trigger part works. My test python ...
0
votes
1answer
35 views
Specify the connection_factory to SQLAlchemy's create_engine()
I have a custom connection factory class (which inherits from psycopg2.extensions.connection) that I would like SQLAlchemy to use. From the create_engine() documentation,
**kwargs takes a wide ...
0
votes
1answer
38 views
Why do I need to dispose a postgresql sqlalchemy engine?
>>> import subprocess, sqlalchemy
>>> engine = sqlalchemy.create_engine("postgresql+psycopg://myuser:secret@localhost/mydb")
>>> subprocess.Popen(['/usr/bin/dropdb', '-U', ...
0
votes
2answers
52 views
Adding a simple search to a Django app
So I'm following this tutorial in order to search some of my models. However, there is a lack of documentation for what is provided and as someone new to Django, I'm confused as to what is missing in ...
0
votes
1answer
29 views
cx_freeze fails to import psycopg2 shared lib at runtime
I have built an executable using cxfreeze (inside a python3.2 virtualenv) on my local machine.
The executable runs correctly on the local machine.
I'm trying to run the executable on a separate ...
0
votes
1answer
27 views
SQLAlchemy many:many relationship, setting uniqueness of a table entry
I'm using SQLAlchemy with Postgres and declarative base and have something along the lines of this many-to-many relationship:
user_trait_association = Table('user_trait', Base.metadata,
...
0
votes
1answer
27 views
Error installing psycopg2 on Windows using pip and virtualenv
I'm following Heroku's "Getting started with Django on Heroku" article and am getting a long series of errors on "pip install psycopg2". Django 1.4.3 and PostgreSQL 9.2.2 are already installed, and ...
0
votes
1answer
72 views
Django form to query database (models)
So I want to create a super basic form with a single input field which will be used to query my database.
My model is as follows:
from django.db import models
class Book(models.Model):
uid = ...
2
votes
2answers
389 views
install openerp 7 with db server on different machine
I am trying to install openerp 7 on ubuntu 12.04 inside a lxc container. The db server is on the host machine. Everything worked fine but when I try to access the webclient for the first time I get an ...
1
vote
0answers
40 views
Re-init migrations in South with Django [duplicate]
Possible Duplicate:
What’s the recommended approach to resetting migration history using Django South?
I have a fairly old Django application running that's been in the hands of several ...
1
vote
1answer
46 views
Update a PostgreSQL array using SQLAlchemy
I'm trying to update an integer array on a PostgreSQL table using a SQL statement in SQLAlchemy Core. I first tried using the query generator, but couldn't figure out how to do that either. I believe ...
0
votes
1answer
64 views
Django/Python: Update the relation to point at settings.AUTH_USER_MODEL
I'm completely new to Python and Django, but I need to install testbedserver-software (for which I follow this tutorial) on my server. Now I'm running into trouble when running following command:
...
2
votes
1answer
66 views
django test app error - Got an error creating the test database: permission denied to create database
When I try to test any app with command (I noticed it when I tried to deploy myproject using fabric, which uses this command):
python manage.py test appname
I get this error:
Creating test ...
1
vote
2answers
48 views
Python/Django and HTML/CSS/JS/jQuery on PostgreSQL/Apache?
I did the courses for HTML/CSS/JS/jQuery/Python on Codecademy and since then I've been practising the 'client side' programming with HTML/CSS/JS/jQuery following documentation/tutorials using ...
0
votes
1answer
29 views
Django models, how to specify foreign key on multiple columns?
So I want something similar to this:
CREATE TABLE orders(
ord_no integer PRIMARY KEY,
ord_date date,
item_code integer ,
item_name character(35),
item_grade character(1),
ord_qty numeric,
ord_amount ...
4
votes
2answers
97 views
How to make field in OpenERP required only for specific workflow state?
In my OpenERP installation I have the following field, which wasn't required before, but I changed the required argument to True.
'fiscal_position': fields.many2one('account.fiscal.position', 'Fiscal ...
0
votes
0answers
42 views
django from 1.3 to 1.4.2 -> DatabaseError: current transaction is aborted, commands ignored until end of transaction block
DatabaseError: current transaction is aborted, commands ignored until
end of transaction block
I started getting the above error, when I upgraded from django 1.3 to 1.4.2.
Whenever I click ...
0
votes
1answer
22 views
Timestamp on new object in heroku app is set to heroku's server start time, not actual utcnow time
I've got an app on heroku that is setting incorrect timestamps for new objects. I can't figure out why for the life of me.
What's happening:
I'm submitting a form on the heroku-run website.
Django ...
0
votes
1answer
60 views
Which one scales better? ORM's distinct() or python set()
and happy new year!
I have a model which will hold some hundreds of thousands of records. The model looks like this:
class Transaction(models.Model):
user = models.ForeignKey(User)
client = ...
0
votes
3answers
71 views
Error: No module named [filename]
I'm building a Django app and am in the process of migrating to Heroku and Heroku Postgres. When I run "python manage.py runserver" or even "heroku run python manage.py runserver" Terminal returns the ...
1
vote
2answers
130 views
postgres and python
In postgres 9.2 I am trying to create a python program that can be a trigger. I want to run an external program (an exe on the local disk) so I am using python to run it. When I try to create a ...
0
votes
2answers
79 views
Puzzling encoding inconsistency with python, Flask, psycopg2
I am using postgres with a psycopg2 python/flask web app.
I am having an encoding problem that I'm sure is something stupid I'm missing (I'm new to programming). The following statement works ...
2
votes
2answers
93 views
Python psycopg2 - Logging events
I'm using psycopg2, and I have a problem with logging events(executed queries, notifications, errors) to a file. I want to get effect like in PgAdmin history window.
For example I'm executing this ...
1
vote
1answer
34 views
Fill pytable using SQL query
I would like to use a dataset equivalent in Python. I want to fill a dataset with data using psycopg2's cursor.fetchall() and then all future queries from this dataset.
I have learned that pytables ...
0
votes
1answer
29 views
Psycopg2 Symbol not found: _PQbackendPID Expected in: dynamic lookup
Im getting this error when trying to run python / django after installing psycopg2:
Error: dlopen(/Users/macbook/Envs/medint/lib/python2.7/site-packages/psycopg2/_psycopg.so, 2): Symbol not found: ...
1
vote
1answer
37 views
cursor.copy_from failed in postgres
I am facing problems in coping data from one db to another db here is python code.
import psycopg2
db = psycopg2.connect("dbname='db' user='xx' password='xx' host='127.0.0.2'")
st = db.cursor();
...
5
votes
2answers
121 views
SQLALchemy DB Session with Flask, Postgres
I'm using SQLAlchemy with Flask as shown here: http://flask.pocoo.org/docs/patterns/sqlalchemy/
I have a Selenium test suite that first runs with Firefox and then with Chrome.
Before the start of ...
0
votes
1answer
44 views
Sqlalchemy Nested Query Returns Wrong data
I have this SQL expression:
SELECT count(*), date_trunc('day', data)
from (
select max(hc.acesso) as data
from historico_comunicacao hc
join cliente c on (c.id = hc.id_cliente)
group by c.id
having ...
0
votes
1answer
29 views
Copying a table using psycopg2 copy_from and copy_expert?
I want to copy table rows from an old database into a new one using the copy commands available in psycopg2. I thought I could redirect through StringIO like the following
io = StringIO.StringIO('')
...
1
vote
4answers
82 views
SQL - find entry which matches the current date
Following Table (let's name it validity_period):
-------------------------------
id | valid_from | valid_until
-------------------------------
1 2012-11-12 2012-12-02
2 2012-12-03 NULL
...
0
votes
2answers
96 views
Heroku tutorial error running python manage.py syncdb to update local database
This question has been asked before and answered here, and I understand the reasoning as to why I am getting the error, however I am still unclear about the solution from the answer given. What code ...
2
votes
1answer
36 views
PostgreSQL multidimensional arrays in SQLAlchemy, not sure of syntax
I'm creating a schema for my DB using PostgreSQL and SQLAlchemy in declarative base and ran into a question that I think is answered but I'm somehow getting the syntax wrong.
I'm thinking of having ...
0
votes
1answer
47 views
Python Pyscopg: How do I use place holders with LIMIT/OFFSET and WHERE?
I am currently trying to use place holders in my PostgreSQL query within Python's psycopg's module. Here is a sample of the code I am using.
table.execute('SELECT * FROM table WHERE col2 = %s ORDER ...