Tagged Questions
0
votes
1answer
6 views
Can I use Psycopog2's LoggingConnection with SQLAlchemy?
I am using SQLAlchemy 0.9.7 over Postgres with psyopg2 as the driver.
I have a stray transaction that isn't being closed properly, and in order to debug it, I would like to log all of the operations ...
0
votes
2answers
25 views
Syntax error in FOR loop declare section
I'm attempting to use a FOR loop in Postgres to calculate data averages over a range of (variable) for each geolocation in my db. I am using python/psycopg2. Here is the code:
query ='''
DECLARE ...
0
votes
1answer
32 views
Django Model BooleanField, not required, but also not null choice
It doesn't seem like the Django model.BooleanField has an attribute for required, only for a null choice. However, I only want a "Yes", "No" choices without the null choice, without forcing the user ...
1
vote
1answer
32 views
Postgres: Is there a way of executing code following a INSERT statement?
This may seem strange, but I was curious to know if it was possible for a code block to be executed following an INSERT statement in a postgres database?
Specifically, I'm interested in executing ...
0
votes
1answer
22 views
Django + Postgres + Large Time Series
I am scoping out a project with large, mostly-uncompressible time series data, and wondering if Django + Postgres with raw SQL is the right call.
I have time series data that is ~2K objects/hour, ...
1
vote
1answer
35 views
Handle and display large data set in web browser
I am still a noob in web app development and sorry if this question might seem obvious for you guys.
Currently I am developing a web application for my University using Python and Django. And one ...
0
votes
0answers
17 views
How to create a table, load data, and then add indexes using SQLAlchemy
I have a python file which uses SQLAlchemy to define all the tables in a given database, including all the applicable indexes and foreign key constraints.
The file looks something like this:
Base = ...
0
votes
1answer
22 views
How to skip empty lines in csv file when reading with python script?
I have a python script in which I want to read a csv file and then import this data into a postgres table. Unfortunately the csv file is quite messy and has many blank lines.
arg = {
'date': ...
0
votes
1answer
10 views
Connecting to remote PostgreSQL database with SQLAlchemy using SSH tunneling with public key and passphrase, all that from a Windows machine
So, I am using Windows to connect to remote Postgres database with a tool like Navicat. I am trying to achieve the same thing using Python (2.7) and SQLAlchemy (0.9) but with no success.
So, my ...
4
votes
1answer
67 views
Robust approach for building SQL queries programmatically
I have to resort to raw SQL where the ORM is falling short (I'm using Django 1.7). The problem is that most of the queries end up being 80-90% similar. I cannot figure out a robust & secure way to ...
0
votes
0answers
11 views
How can I change an ADORecordset's Update Criteria property in Python?
My company has been using ADO to access PostgreSQL databases in Python for years. Occasionally, in programs written in C++ and using ADO and ODBC, we get exceptions saying "Query-based update failed ...
0
votes
2answers
29 views
python manage.py syncdb fails with "ImproperlyConfigured: No module named 'psycopg2'
I am currently going through these steps to install my first Digital Ocean server, with Ubuntu 14 x32 and Django 1.7, using Python 3.4. I'm new to both Ubuntu and Digitial Ocean, although I developed ...
0
votes
2answers
34 views
Inserting a NULL/Empty value into real field Postgres SQL
I have an insert string into my table, but some values are empty which isn't an issue as these values should be intentionally left blank. I'm looking for a smart way to handle this without needing to ...
0
votes
1answer
31 views
Python error: Not all arguments converted during string formatting
I am running the following code segment to print a jasper report in OpenERP
prev_open_fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('state', '=', 'draft'), ('date_start', '<', ...
0
votes
0answers
20 views
Cannot start server on fresh Django Heroku setup
I am attempting to follow this django heroku setup documentation... but I am running into some problems when trying to start foreman.
(Note, I am running windows 7)
Steps I am following (in git ...
0
votes
0answers
47 views
Django Queryset method .delete() not working
Correction: I've said the deletion doesn't work at all. That's wrong. It works most of times, for the same objects/records. It is just unstable: a few hundreds out of thousands of calls don't delete, ...
1
vote
0answers
25 views
SqlAlchemy How to add this class to database
I have a class, that has an array of another class like this
class Episode :
def __init__(self, t, l) :
self.title = t
self.link = l
class Show :
episodes = []
def__init__(self,m)
...
0
votes
1answer
13 views
Substituting variable into SQLAlchemy / Postgresql Query
I'm trying to run a SQLAlchemy query in my Flask app using. I want to grab the URL parameter ('menu') and substitute it's value into my query...
@app.route('/attend/')
def attend_by_role():
role ...
0
votes
0answers
19 views
<type 'exceptions.ValueError'> invalid literal for long() with base 10: 'My-Library-Name'
I'm writing a query code in controller:
books=db(db.book.lib_name=="My-Library-Name").select(db.book.title, db.book.ISBN, orderby=db.book.title)
but I keep getting this error:
<type ...
0
votes
1answer
18 views
Python psycopg2: Access Tuple
We have a PostGres Database which I am accessing with Python. When Querying for a column with type bigint I get back a dictionary with in the following format:
[[263778L], [30188L], [97L], ...
0
votes
1answer
28 views
pg8000 and cursor.fetchall() failing to return records if the number of records is moderate
I'm using the adaptor pg8000 to read in records in my db with the following code:
cursor = conn.cursor()
results = cursor.execute("SELECT * from data_" + country + " WHERE date >= %s AND date ...
0
votes
1answer
43 views
Python: unable connect with database
Python 3.4 with psycopg2
I used this guide to set up a basic psycopg2 connection like so:
#!/usr/bin/python
import psycopg2
import sys
import pprint
def main():
conn_string = "dbname='CIBTST' ...
0
votes
0answers
19 views
SQLAlchemy bug (?) triggers “(ProgrammingError) table name […] specified more than once”
SQLAlchemy (0.8.7 and also 0.9.7) is generating bad SQL for Postgresql 9.3, and I suspect it is a bug, but I am not confident enough yet to dismiss user error.
Here is a snippet of my test-case code.
...
0
votes
0answers
11 views
How to set up Django to run tests on PostgreSQL on Travis CI?
I cannot seem to figure out how to integrate my current Django project to run tests on Travis CI. Right now I have PostgreSQL set up to run on my local machine when unit tests are run.
language: ...
0
votes
1answer
36 views
RuntimeError: maximum recursion depth exceeded while calling a Python object while getting polygon points fron DB
I m trying to draw the stored polygon points on google map when user clicks on the map. I use postgres database. I successfully stored the polygons into DB. When i try to auto draw the polygon points ...
0
votes
0answers
25 views
slow plpython2u postgres execution
postgres 9.3.0, freebsd 9.1, python 2.7.6
I have 3 queries, here they are executing in sql from a file.
begin;
update public.tmp_configuration set data = '{"test": "this"}' where installation_id = ...
0
votes
2answers
35 views
How to check for empty cells in csv before converting to int (Python script)?
I am new to stackoverflow and python so please forgive me if this question lacks detail
I want to import data from a csv file to a table in Postgres. However, I'm not sure how to check for null ...
0
votes
0answers
6 views
Django CONN_MAX_AGE failures with postgresql max_connections
Since I'm using CONN_MAX_AGE: 300 on my Django servers, request fail with errors because PostgreSQL exceeds the max_connections limit (which is 100 by default).
What is the best strategy to solve ...
0
votes
1answer
32 views
How to use databases that are using for java web application in django framework?
I have databases that are used another web application, i want to use same databases for django application. I have the idea i can call the database by using db cursor but i want to use database as ...
0
votes
2answers
35 views
Querying a form in Django 1.5
I need to make a CRUD operation over a form a I have in Django, but i'm confused in how to achieve this. I mean there are different situations and approaches to what I'm looking for.
Consider this ...
0
votes
1answer
16 views
How do I express a function that returns a setof record in sqlalchemy?
I need to execute a pg function that returns a setof record type.
Here is the function in postgres:
CREATE OR REPLACE FUNCTION testfunction(text, text)
RETURNS SETOF RECORD AS
'select * from ...
0
votes
0answers
17 views
Python 2.7, use Pandas/SQLAlchemy to save to Postgres with SET ROLE
I would like to use the Pandas (0.14.1) module with SQLAlchemy support to save a Pandas dataframe as a Postgres table.
DF.to_sql(...) works as expected, of course. However, due to the permissions ...
1
vote
1answer
28 views
Can I change the type of Model Field?
Say, I have a model with this field:
is_retired = models.NullBooleanField()
It has never been set for any of the records i the database, so I think all the records will have a null value for this ...
0
votes
1answer
23 views
Django ORM unique_together not working
I'm working with django 1.6 and postgressql. I'm trying to set up a composite unique key made up of name and addresses fields. My Model:
class MU2(models.Model):
name = ...
-1
votes
0answers
32 views
Pandas pickeling
I have a script that has few postgres queries. I connecting to the database via sqlalchemy.
ALso I have a list of names for which I have to run the script. The dataset obtained in the end of script is ...
0
votes
1answer
30 views
How to trim leading character before importing to postgres?
I have a python script that first converts an xls file to csv and then I have another script that imports this csv file into a postgres table - the UPCs in my file have leading characters that I do no ...
1
vote
1answer
23 views
How to prevent inconsistent reads in django
I have a problem with django and postgresql.
Suppose one process have been loaded some model.
user = User.objects.get(pk=1)
#user.foo is '' right now
user.foo = 'bar'
And while this process doing ...
0
votes
0answers
26 views
Python Extract Script - Google Analytics
I am creating a PostgreSQL db of all my clients' Google Analytics data. My script currently pulls all the data by day. Here is the current query response:
def _build_response(self, feed, profile_id, ...
0
votes
1answer
72 views
Python's 'python manage.py syncdb' draws a blank forever
I am new to Django (but not to Python). I've installed Postgresql 9.3, PgAdmin3 and Psycopg2 successfully in Ubuntu Linux and tested Postgresql manually by creating a database called mysite and a few ...
0
votes
2answers
30 views
How to get the record causing IntegrityError in Django
I have the following in my django model, which I am using with PostgresSql
class Business(models.Model):
location = models.CharField(max_length=200,default="")
name = ...
0
votes
1answer
20 views
Basic handling of unique column IntegrityError with django ORM
I have the following in my django model, which I am using with PostgresSql
class Business(models.Model):
location = models.CharField(max_length=200,default="")
name = ...
0
votes
3answers
45 views
South Migration Issues
I have looked at these questions; http://south.readthedocs.org/en/latest/tutorial/part1.html, South ignores change in field default value in Python / Django & Django-south not detecting DB changes ...
1
vote
3answers
63 views
Using %s commands in execute statements (python) in mySQL vs postgreSQL?
I've been writing code recently in python that works with postgreSQL databases, and it looks like the following:
def insert(table, ID, date, timestamp):
cur.execute("""INSERT INTO %s (ID, date, ...
0
votes
0answers
27 views
multiple queries with multiple threads and multiple connections
I have a very large database of 10 million rows and for that i have a single server so i have decided to split the big table of 10 million row into 4 parts and perform search (select) operation on the ...
0
votes
1answer
12 views
how to apply sql binding in Python and Postgresql using “ilike”
I'm trying to figure out how to apply sql binding in Python and Postgresql using ilike.
I tried any of the below but it didn't work.
title_value = "The"
stmt = "select id from titles where title ...
0
votes
0answers
20 views
Column does not exist in PostgreSQL
I have a query for postgre :
SELECT * FROM "Table1" as "tbl1" INNER JOIN "Table2" as "tbl2" ON "tbl1"."id"="tbl2"."id"
It works fine, but when I use
SELECT "tbl1"."name","tbl2"."name" FROM "Table1" ...
0
votes
1answer
36 views
Data insertion with Date and TimeStamp format into PostgreSQL
I have several weather-related fields such as date_of_data_collection, time, temperature and relative humidity. I have to insert the values of these fields into PostgreSQL. Also, I want to use date ...
0
votes
0answers
36 views
Python inserting data for the correct month into database
So we have code that has been working for a while except this month.
We made some changes and I wasn't involved in the changes but I am in charge of fixing the error.
Now whats weird is in every ...
-2
votes
0answers
15 views
Getting an error in Postgres [duplicate]
I have a webservice in Python that I want to test. For that, I have my curl command that I am running on Terminal. But this is giving me a big list of error traceback from which I think that the ...
0
votes
1answer
36 views
Source code prompts data has been saved but no data appears in table. Using pyCharm and Postgres for development
I have a source code which saves a set of data/inputs from the web page I developed. The web page prompts that the data has been saved but upon looking to the table, no records has been saved. I'm ...