0
votes
1answer
11 views

Python psycopg2 check row exists

In Python psycopg2 how can I check if a row exists? def track_exists(self, track_id): cur = self.conn.cursor() cur.execute("SELECT fma_track_id FROM tracks WHERE fma_track_id = %s", ...
0
votes
1answer
33 views

Django South Error: AttributeError: 'DateTimeField' object has no attribute 'model'`

So I'm trying to migrate a table by adding two columns to it. A startDate and an endDate. Using south for Django, this should be a simple migrate. I have loads of other tables with dateTimes in them ...
0
votes
0answers
35 views

How do I make stat_smooth work in ggplot-python?

That's my code: import pandas as pd import pandas.io.sql as sqlio from ggplot import * from db import conn sql = "SELECT * FROM history WHERE time > (NOW() - INTERVAL '1 day')::date" df = ...
1
vote
0answers
36 views

Django query slow on profiler but fast on PostgreSQL

Django-live-profiler is showing me a query executed a huge number of time with a slow average time. So the total execution time of the request is high. When I execute the same request directly on ...
0
votes
1answer
26 views

Django datetimes queryset in 1.5

How to get the new Django 1.6 datetimes queryset in Django 1.5 assuming I've postgres database? Ref datetimes here: https://docs.djangoproject.com/en/1.6/ref/models/querysets/#datetimes I want a ...
1
vote
2answers
42 views

Generate a random alphanumeric string as a primary key for a model

I would like a model to generate automatically a random alphanumeric string as its primary key when I create a new instance of it. example: from django.db import models class ...
0
votes
0answers
31 views

Django Test Error: relation does not exist

I'm using Django 1.6 with Python 3.3 on Ubuntu 13.10 and Postgres. I have a model User defined as follows: from django.db import models from django.contrib.auth.models import AbstractUser from ...
1
vote
0answers
24 views

SQLAlchemy: Join to subquery with no from field

I have a table called product_model with its corresponding ProductModel SQLAlchemy model. I wish to join the product_model table to a select sub query which simply unnests two PostgreSQL arrays ...
1
vote
2answers
33 views

SQLAlchemy autoload insert record

PostgreSQL has table student: Table "public.student" Column | Type | Modifiers ...
0
votes
1answer
19 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
19 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
23 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 ## ...
1
vote
0answers
17 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
70 views

Which database to use with Django and Python 3? [closed]

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
25 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
14 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
25 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
44 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
30 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
31 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
59 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
18 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
31 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
19 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
21 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
25 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
45 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
33 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
22 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
38 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
223 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
15 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
55 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
72 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
43 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
16 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
37 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
27 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
23 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
25 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
15 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
35 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
38 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
83 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
35 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
64 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
31 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 ...

15 30 50 per page