Tagged Questions
0
votes
1answer
15 views
Return a mapped dictionary based on multiple queries
Issue: I can't figure out how to run a query in the correct way so that it returns a mapped dictionary. The query will use counts from multiple tables.
I am using psycopg2 for a postgresql database, ...
0
votes
0answers
12 views
How to add PostgreSQL to Aptana 3 PyDev project?
I am working through this article which uses SQLite for it database. But I prefer to use PostgreSQL because I plan to deploy my app on Heroku. So how can I add PostgreSQL to my Aptana 3 PyDev project?
...
0
votes
1answer
10 views
Best approach to detect subnet overlap in a postgresql db
I've got a postgres db with nearly 200'000 network address types.
I'd like to detect if some subnets are overlapping themselves, for ex, detect 123.0.0.0/16, 123.2.0.0/24 and 123.3.4.128/30 and report ...
11
votes
3answers
5k views
Checking if a postgresql table exists under python (and probably Psycopg2)
How can I determine if a table exists using the Psycopg2 Python library? I want a true or false boolean.
3
votes
1answer
90 views
gevent and posgres: Asynchronous connection failed
I'm using gevent to handle API I/O on a Django-based web system.
I've monkey-patched using:
import gevent.monkey; gevent.monkey.patch_socket()
I've patched psychopg using:
import psycogreen; ...
2
votes
1answer
20 views
case sensitve query returns string instead of list
I have an issue executing a query using python's pgdb using multiple case sensitive columns. The results of most queries return a python list, but if I issue a query against a table specifying ...
0
votes
1answer
41 views
How do I relate data without one single master or starting point
I have a set of "people" data that contains identity numbers. This data comes from various sources in a format like below
Source1: IDNumber:I1, Passport:P1,SocialSecurity:S1,DateOfBirth,13/03/1967
...
1
vote
1answer
41 views
python xml to string, insert into postgres
Here is my code:
#!/usr/bin/python
import psycopg2
import sys
from lxml import etree
def main():
#Define our connection string
conn_string = ("host=host dbname=lal user=user password=pass")
...
0
votes
2answers
45 views
Python output file with timestamp
Hi guys I have a little problem with output my file with time stamp here is my code
input_file = open('DVBSNOOP/epg_slo_sort.txt', "r") # read
output_file = open('SORT/epg_slo_xml.txt', "w") # write ...
0
votes
1answer
25 views
I can't populate table from postgres to django model
I have following problem. I've created table 'users' using postgres database, then I've created model:
from django.db import models
class Users(models.Model):
name= models.CharField(max_length=30)
...
1
vote
0answers
19 views
Reset Django database while running
I'm trying to reset my database while Django project's running but I'm having a trouble. Django is constantly interacting with the database due to his mapping between database and models.
I'm using ...
0
votes
2answers
42 views
Django IntegerField returns ExpressionNode
I got a model containing two counters :
class MyObject(models.Model):
...
student_c = models.PositiveIntegerField(default=0, blank=True, null=True)
company_c = ...
0
votes
2answers
37 views
postgres commands working in shell but not in python script
I am trying to create a postgres database, using a dumpfile, from a python script.
Following is the code I tried:
cmd='cat dump.sql.gz | zcat - | PGPASSWORD=my_password psql -d voylla_solr -h ...
0
votes
2answers
34 views
Selecting the rows with the N most recent unique values of a datetime
I have a postgres DB in which most of the tables have a column 'valid_time' indicating when the data in that row is intended to represent and an 'analysis_time' column, indicating when the estimate ...
1
vote
2answers
39 views
How to make sqlalchemy session keep track of all changes in the locally created objects?
Sqlalchemy keeps track of all the changes and commit to the database if I do this:
b = this_session.query(BaseUrl).filter_by(id=value).first()
b.basevalue = "new_value" #changing
...