Tagged Questions
0
votes
0answers
7 views
Postgres ILIKE Query with Flask/SQLAlchemy
I have the following model:
class Post(db.Model):
id = db.Column(db.Integer, primary_key = True)
title = db.Column(db.String(250))
content = db.Column(db.String(5000))
I'd like to run a ...
1
vote
2answers
14 views
Return PostgreSQL hstore as OrderedDict using psycopg2 in Python
A PostgreSQL hstore maintains order between storage and retrieval. This allows one to define the order in which the keys/values within the hstore are stored and retrieved.
Unfortunately, psycopg2's ...
0
votes
0answers
20 views
Is this postgresql logging handler correct?
I'm trying to develop a logging handler for PostgreSQL. I've used this gist as a template and changed that to suit my needs as
# -*- coding: utf-8 -*-
import psycopg2
import logging
import time
## ...
0
votes
0answers
11 views
why sqlalchemy default column value not work
I am using postgresql 9.1 and sqlalchemy 0.9 in ubuntu 12.04
The problem is, 'default=10' not work.
My Code:
conn_str = 'postgresql://test:pass@localhost/test'
engine = create_engine(conn_str)
...
0
votes
1answer
53 views
Which database to use with Django and Python 3? [on hold]
I'm writing my first application with Django and Python 3.3.3. I've always used MySQL for others projects, but it seems to have some problems with Python 3.X and MySQL :
At the time of writing, ...
-2
votes
0answers
24 views
Coding a report in Python using data from a Postgresql database
I am trying to code in python in order to get a report on prices depending on their taxes.
the template is as follows:
04|85|%s|||||%s|||%s||||||||%s||||
22 columns total, first two columns always ...
0
votes
0answers
13 views
How to setup geoDjango project in eclipse
I am working on project related to geoDjango and i have no experience on this.
I have searched but cannot found any tutorial or demo related geoDjango on eclipse. I have created simple django project ...
0
votes
1answer
24 views
SSH python library [closed]
I have a question about a ssh python library.
I plan to use ssh to communication between Windows and Linux environment.
A typical user will be on a Windows environment and will need to access to ...
1
vote
2answers
38 views
Django: How to write query to sort using multiple columns, display via template
I'm quite new to Django, and not too experienced with MVC, DB queries.
I have a Customer table which includes customer_name, city_name, as well as a state_name (pulled from a foreign key table). In ...
0
votes
1answer
28 views
sqlalchemy: cannot save model with Date column
I have created a model via declarative_base:
Base = declarative_base()
class Record(Base):
__tablename__ = 'test'
id = Column(BigInteger, primary_key=True)
datefrom = Column(Date)
...
0
votes
0answers
28 views
How to delete multiple rows with 2 columns as primary key in PostgreSQL?
I'm looking for a solution in Postgres to the following problem:
delete multiple rows in a table with a composite primary key
I found the solution for MySQL here but it doesn't work for Postgres
...
0
votes
1answer
43 views
psycopg2.InterfaceError: connection already closed / pgr_astar
I am using psycopg2 to access a postgresql database from python. When I try to run the pgrouting function "pgr_astar" for the shortest path, I receive an error
cur = db.cursor()
...
0
votes
0answers
17 views
Django with postgresql: auto_increment field starts at 0 after deserialization
On my production postgresql database, in heroku, I've used django deserialization to populate models from json files.
On sqlite this works fine. However on postgresql it seems that all the autofields ...
0
votes
0answers
26 views
how to connect a postgresql database using pyodbc and freetds
I m trying to connect a postgres sql database which is in another ubuntu pc from my ubuntu11.10. But i cant able to connect. I m using Python 2.6 .
ConnDb.py :
import psycopg2.extensions
import sys
...
0
votes
3answers
31 views
Having trouble with a PostgreSQL query
I've got the following two tables:
User
userid | email | phone
1 | [email protected] | 555-555-5555
2 | [email protected] | 555-444-3333
3 | [email protected] | 333-444-1111
4 | [email protected] ...
0
votes
0answers
18 views
Working with pending trigger event in Django 1.4
@transaction.commit_on_success
def action_init_address_receipt(cls, request):
execute_sql('alter table finance_addressreceipts disable trigger user;')
execute_sql('select ...
0
votes
1answer
19 views
Python + psycopg: type '23' for column when in fact 'double precision' in postgresql database
I use psycopg2 in python to access a postgresql database.
I first collect rows with a fetchall:
rows=cur.fetchall()
Then, for each row, I modify the type from postgresql format to python format:
...
0
votes
1answer
22 views
Django HStore: How to override a key-value model field's __getattr__ and __setattr__
I've been getting my feet wet with using hstore in Django, through the django-hstore module. A big advantage to using hstore is that it allows for key-values to be stored in a field while providing ...
0
votes
1answer
38 views
pg.InternalError: SSL SYSCALL error: EOF detected
I have a code in python using multiprocessing and accessing a database. It works most of the time properly but from time to time it creates an error. The error was originally
File ...
1
vote
1answer
27 views
SQLAlchemy + PostgreSQL + PG regex
SA has support for regexes but those seem to be Python regexps (Regular expressions in SQLalchemy queries?)
I need to use regex on matching some rows (a row contains 1 log line, so regex is a natural ...
0
votes
1answer
20 views
Why does django/tastypie with postgresql concatenate models_?
I am using postgresql with django and tastypie. I have my models and resources set up and working with mongodb for certain models and am trying to use postgresql for relational data models. For some ...
0
votes
0answers
37 views
Does a high CPU usage -say 98%- necessary mean the database will be slower? [migrated]
I have 4 python scripts each running in their own virtual machine. The scripts are accessing a central postgresql database. All scripts are reading from the same table but posting to different tables ...
1
vote
2answers
110 views
Mac + virtualenv + pip + postgresql = Error: pg_config executable not found
I was trying to install postgres for a tutorial, but pip gives me error:
pip install psycopg
A snip of error I get:
Error: pg_config executable not found.
Please add the directory containing ...
0
votes
1answer
14 views
SQLAlchemy misses data on query when parameter is datetime.date
I have a Transaction model where one of the fields is
transaction_date = Column('transaction_date',
sa.types.DateTime(timezone=True),
...
1
vote
2answers
50 views
“ProgrammingError: column ”genre_id“ of relation ”music_album“ does not exist” while the column does exist
I have the following models :
class CulturalDocument(CacheMixin, models.Model):
...
uuid = UUIDField(unique=True)
class Genre(CulturalDocument):
name = models.CharField(max_length=32)
...
0
votes
2answers
61 views
pip install psycopg2 venv freezing
So I'm trying to install psycopg2 in a virtualenv so that I can deploy a Django app to Herkou. I ran into a pg_config executable not found error, so I reinstalled PostgreSQL, but this time via ...
0
votes
0answers
40 views
Postgre/SQLAlchemy UUID inserts but failed to compare
I am accessing Postgre database using SQLAlchemy models. In one of models I have Column with UUID type.
id = Column(UUID(as_uuid=True), default=uuid.uuid4(), nullable=False, unique=True)
and it ...
0
votes
1answer
15 views
Why would we need to have multiple search vectors per class? (sqlalchemy-searchable)
I was going through the sqlalchemy-searchable docs and they have provision for multiple search vectors for same class. Why would this be useful?
for example (from the docs)
class Article(Base):
...
0
votes
0answers
34 views
How to create in SQLAlchemy model row with random string when Postgresql is under?
How to create in SQLAlchemy model row with random string when Postgresql is under?
I need to convert from MySQL where I can do like this.
Column(uuid_generator.GUID(), default=uuid.uuid4, ...
0
votes
0answers
25 views
Django tests don't find the postgres extensions
I am running python tests like this.
python manage.py test
.....
[snip]
.....
LINE 1: SELECT (idx([snip])...
^
HINT: No function matches the given name and argument types. You ...
-1
votes
1answer
19 views
Hibernate in python (using socket) [closed]
i'm trying to do a client/server application using python and postgresql.
Is there a kind of framework like hibernate to python?
1
vote
1answer
24 views
Python postgres output formatting
I'm using psycopg2 and I'd like to know if there's a way to generate some cleaner output from my SELECT statements.
My data looks like this in the database:
("Apple" user:(Apple) tag:(Apple))
When ...
1
vote
1answer
28 views
SQL within Django - “order” field for the records in table - defined by user, can be arbitrary, changes constantly - how do I do this?
So I have an application in which a user creates a list. The user also orders the items in the list and can add and remove items from the list. If the user logs out and then logs in from another ...
0
votes
0answers
14 views
DJango creating a model of existing table with bigserial
I'm using DJango 1.6 with python 2.7, I have an existing postgresql+postgis database
the tables declare a column of type bigserial as their primary key
for example:
CREATE TABLE MMCompany
(
...
0
votes
1answer
30 views
DJango 1.6 model.BinaryField causes TypeError
I've created a class model using DJango 1.6 with python 2.7 as follows:
class Company(models.Model):
Name = models.CharField(max_length=150)
PhoneNumber = ...
0
votes
0answers
26 views
COPY FROM error in cqlsh Cassandra newline character seen in unquoted field
I am attempting to import a tab delimited file (or a csv for that matter) using cqlsh into a Cassandra keyspace. In Postgres I would simply use:
copy alaska_chinook (year, count_date, fish_count, ...
0
votes
0answers
71 views
trying to create a simple flask service to connect to postgresql database
newbie to flask & compute engine
I've created a database (myDB) with table user and store procedure insert_user.
now i wish to create a simple python/ flask service that will connect to the ...
0
votes
1answer
28 views
Timing issue (?) between python, bash and psql
I use Pythons os.system, pg_dump and psql to transfer data between Postgresql databases. The command is execute like this:
os.system('set some variables ; pg_dump ... | psql ...')
... process copied ...
0
votes
0answers
29 views
Django postgresql on Heroku DatabaseError value too long for type character varying(1000)
I'm getting this error when saving a Django Model Object:
DatabaseError: value too long for type character varying(1000)
Inside the model there is a textfield:
models.TextField()
I'm saving ...
0
votes
2answers
55 views
Error when attempting to install django-toolkit within a python virtualenv
I'm relatively new to Python, extremely new to Django and Heroku, and also rather new to working in the terminal.
I'm attempting to follow the instructions on setting up a Django Heroku project found ...
1
vote
1answer
28 views
Unable to acquire db connection from Trac?
Attempting to install Apache Bloodhound (which is built atop Trac) on Ubuntu 13.10 x64 server.
I have followed their installation guide precisely (for Postgres).
Error output from ...
0
votes
1answer
45 views
How to union two subqueries in SQLAlchemy and postgresql
Raw SQL desired:
SELECT
id
FROM
(SELECT some_table.id FROM some_table WHERE some_table.some_field IS NULL) AS subq1
UNION
(SELECT some_table.id WHERE some_table.some_field IS NOT NULL)
...
0
votes
2answers
41 views
Psycopg2 Full Outer Join with Python 2.6
I am brand new to using psycopg2 to interact with a postgreSQL database. I am attempting to do a full outer join and cannot find any documentation to help me with the command. Here is what I am ...
5
votes
3answers
148 views
How to show database errors to user in Django Admin
Background: my Django application sits onto top of a pre-existing Postgresql database. This database has a very complex network of triggers and constraints.
Question: In the Django Admin, if a user ...
1
vote
1answer
36 views
GeoDjango touches function is slow
First off, here's my setup:
Python 2.7.6
Django 1.6
PostgreSQL 9.3.1
PostGIS 2.1.1
I have loaded up the Natural Earth countries and states datasets into PostGIS. Here's the Django model I'm using:
...
1
vote
1answer
162 views
Storing the Uploaded image?
I am using a basic WTForms FileField so far i am able to upload the file but its not getting stored in directories but its getting stored in POSTGRESQL database as <Binary data>. How to store ...
1
vote
1answer
55 views
Should I do numerical calculations in-database?
I have a database containing results from many models I've run. I need to calculate each model's chi^2 value. I'm using python and the
psycopg2 package to interface with my PostgreSQL database. ...
0
votes
1answer
32 views
Soaplib connection - msg 's0:FunctionName', not-found
I have problem with solution that was working very good and suddenly it stopped to do so. I wrote server/client scripts and modules to make a SOAP connection type for my application.
Here is my server ...
0
votes
1answer
35 views
Query that excludes rows in a certain table
I have three tables: users, contacts, and groups. I want to find all the contacts of a user, and then from those selected contacts, I want to exclude those contacts of that user that have a particular ...
0
votes
2answers
32 views
os.system with embedded commands
I've now been struggling a long time and still can't get this line of code working :
os.system('su - postgres -c "psql -c \'ALTER USER postgres WITH ENCRYPTED PASSWORD ...