postgresql

To check `0 rows` from the SQL query in Postgres / PHP

How can you check an empty database result and then make an action based this? My code which puts matching result to the if -clause while( $tags_and_Qid = pg_fetch_array( $result_tags )) { // Add the Tag to an array of tags for that question $end_array [ $tags_and_Qid['question_id'] ] ['tag'] [] = $tags_and_Qid['tag']; ...

GIS: line_locate_point() in Python

I'm pretty much a beginner when it comes to GIS, but I think I understand the basics - it doesn't seem to hard. But: All these acronyms and different libraries, GEOS, GDAL, PROJ, PCL, Shaply, OpenGEO, OGR, OGC, OWS and what not, each seemingly depending on any number of others, is slightly overwhelming me. Here's what I would like to do...

Good resources for learning PL/pgSQL?

I've been looking around the net trying to find good resources for learning PostgreSQL's procedural programming language, PL/pgSQL. So far the only thing I've managed to dig up is the tutorial in the PostgreSQL documentation. While that is good, I've been looking for something more in-depth. Can you recommend anything? ...

Automatically generated test data to a DB from a schema?

I have a discussion-db, and I need a great amount of test data, for different sized samples. Please, see the ready SELECT, JOIN and CREATE-queries, please scroll down in the link. How can I automatically generate test data to the db? How to generate test data in different sized samples? Is there some ready tool? ...

How can I use a Postgres Triggers to store changes

Is it possible using postgres and triggers to create update and insert sql statements of changes that have happened to a table and log them to a file for later execution. This is only to be used temporally so just something quick and dirty. Regards, /James ...

JDBC- postgres, connection refused

This is my first time using java to access databases, so I probably have a simple mistake here, but when I go to retrieve my connection from a remote database I have access to, I get a connection refused. Here's the code in question: String url = "jdbc:postgresql:url.isformatted.like.this/database"; try { conn = DriverManager.getC...

SQLAlchemy(Postgres) and transaction

I want a record from a table(queue) to be selected, locked(no other process can edit this record) and updated at a later point in time. I assumed if I put the whole querying and updating in a transaction, no other process can edit/query the same record. But I am not quite able to achieve this. def move(one, two): from settings import ...

Python: Which modules for a discussion site?

A site should be ready in 6 days. I am not allowed to use any framework such as Django. I am going to use: Python modules HTMLGen to generate HTML code from class-based description SQLObject, relational tables onto Python's class model ? Other Python 2.5 A variant of the Postgres schema Super Smack for testing the schema Which m...

Oracle Schema Doubt?

Currently am using postgres with diff schemas for diff modules.Now i am planning to switch towards oracle.But i heard that in oracle schema is not there..Is it true..if it is like that how can i migrate? ...

Multiple database connection in Rails

I'm using active_delegate for multiple connection in Rails. Here I'm using mysql as master_database for some models,and postgresql for some other models. Problem is that when I try to access the mysql models, I'm getting the error below! Stack trace shows that, it is still using the postgresql adapter to access my mysql models! Runtime...

Help me in solving this Postgresql query

The Postgresql query below should return the following date type ti varchar() type but its giving error. I've even tried it with convert(using return also), but still it's giving error. CREATE FUNCTION TimePart( fDate out date ) --RETURNS date AS $$ BEGIN cast(fDate AS char(10)); END; $$ language 'sql' ...

Postgres Query Logging for Windows

I have an application which is based on a Postgres database and I need to be able to examine the requests the application sends of the database. I want to have Postgres log all of the queries it receives somewhere that I can examine them in order to rebuild some of its functionality in another application. Can someone recommend a simpl...

Apache/Django freezing after a few requests.

I'm running Django through mod_wsgi and Apache (2.2.8) on Ubuntu 8.04. I've been running Django on this setup for about 6 months without any problems. Yesterday, I moved my database (postgres 8.3) to its own server, and my Django site started refusing to load (the browser spinner would just keep spinning). It works for about 10 mintue...

Can't change datatype of column in postgres

I'm trying to change the datatype of a column to varchar but get the following error ERROR: syntax error at or near "type" at character 40 My code looks as follows alter table n_logs alter column action type varchar(100); I'm running PostgreSQL 7.4.13 (Yeah, I know I need to upgrade) ...

libpq send integer as binary

I have a libpq program that is routinely inserting numbers into a database. These numbers, which I'm expecting to grow quite large, are stored int the uint64_t type. I'm wanting to send the integer to libpq as binary, but Postgres won't be able to tell its unsigned. Is there a way to specify an unsigned integer in Postgres or libpq? ...

PostgreSQL: What's an efficient way to update 3m records?

A dumbveloper at my work (years ago) moved the body column from our comments table to a secondary comment_extensions table as some sort of sketchy guesswork optimization. It seems ill-advised to do a join every time we want to display a comment, so I'm going to try moving that column back into our comments table and run some benchmarks....

PostgreSQL libpq "Integer out of range" error when sending integer as binary

I'm attempting to insert some integers into a Postgres table with the following somewhat simple code. #include <libpq-fe.h> #include <stdio.h> #include <stdint.h> int main() { int64_t i = 0; PGconn * connection = PQconnectdb( "dbname='babyfood'" ); if( !connection || PQstatus( connection ) != CONNECTION_OK ) return 1; print...

Using npgsql to call a function that takes character as parameter

I am trying to use Npgsql to invoke a function (stored procedure) that takes a CHARACTER as parameter, but it doesn't work. If I declare the same function without parameters, or with an INTEGER parameter, I get the result sets that I want. When I declare the parameter as CHARACTER, it stops working. What is wrong? Here is the code of my...

Sub queries and sorting? (ORDER BY)

So my syntax is apparently correct in all three cases (PostgreSQL isn't grousing about anything) but the results come back in the same order with all three of these queries. Even stranger when I add/remove DESC from any of the following it has no impact either. Is it possible to sort results based on elements of a sub query or not? So...

migrate postgreSQL data to mysql

I'm looking to grab a few bits of data from musicbrainz db to use in a mysql based app. I don't need the entire database, and have been looking at 'migrating' postgreSQL to mysql, which it seems lots of people have difficulty with. Wouldn't it be simplest to just dump the postgreSQL data into a comma-delimited text file, and then imp...