postgresql

Postgresql - escaping dash in username

I'm having difficulty modifying a postgres user that contains a dash in its name - I've run into this problem several times, but can never find the answer (no matter how much googling I do!). osm=# grant all on osm_polygon_view to www-data; ERROR: syntax error at or near "-" LINE 1: grant all on osm_polygon_view to www-dat...

Django(postgresql) + lighttpd. Any issues with threading and python's postgresql driver?

I'd like to deploy my Django app (which uses postgresql as database) on lighttpd using FastCGI. For postgresql i see that Django has 2 backends available 'postgresql_psycopg2' and 'postgresql'. My question is that lighttpd being a threaded server are there any issues with any of this backends? Are they thread safe? And which one of them ...

Possible to condense primary key/serial?

Hello, I have a database where everything is linked with foreign keys, so the Postgres knows exactly how the database is layed out.. Well, Lets say I have Table1 and Table2. Table1 has 3 fields. RID, table2_rid,data So table1.table2_rid references table2.RID and this is expressed with a foreign key. In both the RID field is the prima...

After a PostgreSQL restore, I get "permission denied for relation django_session"

I'm currently running my Django 1.1.1 site with PostgreSQL 8.4.2 both on the live server and locally. When I try to restore one of my backup from the live server on my local box, I get the following error while accessing my site locally(http://localhost:8000): Exception Type: ProgrammingError at / Exception Value: permission denied for...

Postgres Slony-I question

Sample slonik command on the 1st node: slonik <<_EOF_ #-- # define the namespace the replication system uses in our example it is # slony_example #-- cluster name = $CLUSTERNAME; #-- # admin conninfo's are used by slonik to connect to the nodes one for each # node on each side of the cluster, the syntax is that of PQconnectdb in # the ...

django database many2many relationship errors

hi i am using the following models to build a database from django.db import models from django.contrib import admin class Team(models.Model): """Model docstring""" slug = models.SlugField(max_length=200) Team_ID = models.AutoField(primary_key=True) Team_Name = models.CharField(max_length=100,) College = models.Ch...

Possible to rank partial matches in Postgres full text search?

I'm trying to calculate a ts_rank for a full-text match where some of the terms in the query may not be in the ts_vector against which it is being matched. I would like the rank to be higher in a match where more words match. Seems pretty simple? Because not all of the terms have to match, I have to | the operands, to give a query such ...

COMMIT in PostgreSQL stored procedure

Hi, I have a PostgreSQL stored procedure which loops over a very large list, and makes changes to some of its members using UPDATE. Is there a way to commit these changes per iteration, not at the end of the function execution? It would allow me to run the function for shorts periods of time, making small changes at each run. Thanks, ...

postgresql and firewall

I will be building a server/client software on Windows, where many machines need to communicate with a Postresql database running on the server. This is C++ software so I will use libpq to connect to the database. If I do this, will there be issues with the firewall? I'd like to make configuration as easy as possible and not have us...

Composite id in hibernate+postgres breaks due to returned column order

I have a parent object with composite-id (legacy db - can't modify this). I have a child object that is a bidirectional one-to-many (parent-to-children) relationship. The mapping is correct, as I can load an instance of either entity and correctly navigate across the relationship. My problem comes when I store the parent and it cascade...

Using Adodb for php/postgresql, return row ID after insert

I am using Adodb and Postgresql. When I insert a row, it increments the ID field using SERIAL. Is it possible to return the newly created ID number right after the insert? ...

Adodb: Postgresql select from two tables but return one set of results

I am new to SQL, and have two tables that hold data(I am using Adodb). They both have keys that connect them together, so I wanted to select a name from the first table if that has a parent id in the second table. I am using: $db->GetCol("SELECT x_ast.name FROM x_ast, x_ast_tree WHERE x_ast_tree.parent='$parent_id'"); This returns a...

Using views for access control in PostgreSQL

I have a schema of tables whose contents basically boil down to: A set of users A set of object groups An access control list (acl) indicating what users have access to what groups A set of objects, each of which belongs to exactly one group. I want to create a simple application that supports access control. I'm thinking views woul...

Database design for summarized data

I have a new table I'm going to add to a bunch of other summarized data, basically to take some of the load off by calculating weekly avgs. My question is whether I would be better off with one model over the other. One model with days of the week as a column with an additional column for price or another model as a series of fields ...

Postgres Command Line tool for Import/Exporting data/ddl

For Postgres is there any sort of command line utilities that allow a database to be "dumped to a file" and that allow that same database dump to be imported? I know this can be done through PGAdmin, but I need to be able to do this on the cmd line. ...

How can I store the result of a SQL query in a CSV file using Squirrel?

Version 3.0.3. It's a fairly large result-set, around 3 million rows. ...

postgresql order by

Hi. My table has a 'number' column which ranges from 0 to around 1000. I want to select everything from the table while ordering it by number. However, I want the rows with number=0 to appear last. I could do it in two queries: select * from channel_table where number > 0 order by number; select * from channel_table where number = 0...

PostgreSQL bytea Primary Key

I have a table in my database which stores logs. The log files are timestamped with second accuracy and store the values of various sensors and their source: log_id, log_date, primary_system_source, sub_system_source, values Where log_id, primary_source and sub_source are integers and values is a variable length byte array (datatype: ...

Postgresql enum what are the advantages and disadvantages?

Where I work we use a postgres database (8.3 soon to migrate to 8.4). There is a small debate currently on the use of enums in the database. Personally I do not like the db enum type. Among other things it puts application logic in the database and creates a posibility for a mismatch between code and data. I was wondering what exactly ...

How can I limit number of results by a specific column in postgreSQL?

Hi, I have a table with user items. Each user may have several types of items, and may have each item more than once. I want to see how many items of each type each user have. So I use the following query: select user_name, count(item_name) as "count_item", item_name from my_table group by user_name, item_name order by user_name, co...