postgresql

PostgreSQL and C# Datatypes

I search type convertion table between PostgreSQL and C# but I could not find. I'll research empty cell on above table if I have time. But if you know the web page which has these infomation,I'm very appropriate to your help. Postgre Type --->C# Type bigint --->Int64 bigserial ---> bit [ (n) ] --->Byte[] bit varying [ (n) ] --->Byte...

How can I put a database under git (version control)?

I'm doing a web app, and I need to make a branch for some major changes, the thing is, these changes require changes to the database schema, so I'd like to put the entire database under git as well. How do I do that? is there a specific folder that I can keep under a git repository? How do I know which one? How can I be sure that I'm pu...

how to close hibernate tools db connections

When developing a new project I often want to re-create the schema to apply any new entities or relationships created. I like using hibernate tools in eclipse, but it's a pain when wanting drop and re-create the schema - since it seems to maintain open connections to the db (postgres in this case). Does anybody know if there is an easy ...

Refactoring PostgreSQL SProcs

Hi, with a moderate PostgreSQL installation we accumulated quite a few stored procedures/functions and types. Now in the lowest level composite type (i.e. 3 types are built with it and a myriad functions reference any of those types) one element of the type is of wrong type (i.e. smallint instead of bigint), thus handling it is identi...

Storing time-temperature data in DB

I'm storing time-temperature data in a database, which is really just CSV data. The first column is time in seconds, starting at zero, with the following (one or more) column(s) being temperature: 0,197.5,202.4 1,196.0,201.5 2,194.0,206.5 3,192.0,208.1 ....etc Each plot represents about 2000 seconds. Currently I'm compressing the ...

Java Enums, JPA and Postgres enums - How do I make them work together?

We have a postgres DB with postgres enums. We are starting to build JPA into our application. We also have Java enums which mirror the postgres enums. Now the big question is how to get JPA to understand Java enums on one side and postgres enums on the other? The Java side should be fairly easy but I'm not sure how to do the postgres sid...

How Do I Backup My PostgreSQL Database with Cron?

I can run commands like vacuumdb, pg_dump, and psql just fine in a script if I preface them like so: /usr/bin/sudo -u postgres /usr/bin/pg_dump -Fc mydatabase > /opt/postgresql/prevac.gz /usr/bin/sudo -u postgres /usr/bin/vacuumdb --analyze mydatabase /usr/bin/sudo -u postgres /usr/bin/pg_dump -Fc mydatabase > /opt/postgresql/postvac.gz...

Datetime issue in Django

I am trying to add the datetime object of a person. Whenever the birth year is less than year 1942, I get a strange error DataError: unable to parse time when reading the data back from the DB. class Person(models.Model): """A simple class to hold the person info """ name = models.CharField(max_length=100) born = models....

Perl+Postgresql: a function does not return a value if RAISE NOTICE is present

Hi, I noticed that when I call a PL/PgSQL or PL/Perl function from a Perl script using DBI, it does not return a value if a RAISE NOTICE or elog(NOTICE) is used in the function. To illustrate: A simple table: CREATE TABLE "public"."table1" ( "fld" INTEGER ) WITHOUT OIDS; A simple function: CREATE OR REPLACE FUNCTION "public"."fun...

Is there a way to know the name of a calling function in PL/PgSQL?

When I call a PL/PgSQL function (not a trigger) from another such function, is it possible to know the name or some kind of ID of a calling function? ...

Data corruption in PostgreSQL timestamp field

I have a PostgreSQL table with the following schema - CREATE TABLE test ( id serial NOT NULL PRIMARY KEY, username varchar(100) NOT NULL, -- The user name dob timestamp with time zone NOT NULL -- The date of birth ); I then inserted some data into the table with data like this - INSERT INTO "test" ("username", "dob") VALUES (E'...

Learning a bit about some new technologies... any tips?

OBJECTIVE: To learn a little more about some technologies I'm familiar with but not an expert in: Postgres, Compass/Sass, Google Maps API, Twitter API, and ASP.NET MVC 1.0, Flickr API THE SITE: Just a fun little app with CRUD for addresses of my friends, then a page that kind of has a map of where they live, their last five tweets, an...

Database speed optimization: few tables with many rows, or many tables with few rows?

Hi guys, i have a doubt (big). Lets take as example a database for, dunno, a whatever company's orders. Lets say that this company make around 2000 orders per month, so, around 24K order per year, and they dont ant to delete any order, even if 5 years old (hey, this is an example, numbers dont mean anything:) In the meaning of have a ...

How can I write a SELECT statement in which the condition is the result of a function

Hello, I want to write a SELECT statement as follows: SELECT field_a FROM my_table WHERE field_b IN (my_function(field_c)). Is that possible? my_function would have to return an array? I'm using PostgreSQL 8.2 ...

pg_send_query(): Cannot set connection to blocking mode?

I have a long-running script that seems to occasionally report the following NOTICE-level error: pg_send_query(): Cannot set connection to blocking mode It seems to continue to send queries afterward, but it's unclear if it successfully sends the query that generates the error. What is this a symptom of? Edit: There are no entries...

How to add many-to-one relationship in PostgreSQL

I having two table: Stock Master and Stock In, how do i create many-to-one relationship between them, Stock In record many different stock by different date and quantity, but Stock Master must showing and combine same stock with their quantity into one , and must functional first in first out. ...

SQL ORDER BY the 'IN' value list

I have a simple SQL query (in PostgreSQL 8.3) that grabs a bunch of comments. I've composed a bunch of ids before-hand and that gets fed into the WHERE IN clause like so... SELECT * FROM "comments" WHERE ("comments"."id" IN (1,3,2,4)) This returns the comments in a natural order which in my case is the ids like 1,2,3,4. What I'm wan...

Import/update existing rows in PostgreSQL

I am working on a hobby app which will contain a large slew of basically-hardcoded data, as well as dynamic user data once I deploy it. I want the ability to update the hardcoded data locally (more UPDATEs than INSERTs), and then export these data to the server. In other words, I need to dump data to a file, and import it in such a way t...

How to protect a running column within Oracle/PostgreSQL (kind of MAX-result locking or something)

Hi, I'd need advice on following situation with Oracle/PostgreSQL: I have a db table with a "running counter" and would like to protect it in the following situation with two concurrent transactions: T1 T2 SELECT MAX(C) FROM TABLE WHERE CODE='xx' -- C for new : result + 1 SELECT MAX(C) FROM TABLE WHERE CODE='xx'; ...

PostgreSQL Data Connection/Server Explorer in Visual Studio 2008

I'm trying to find a way to browse a PostgreSQL database from the Visual Studio 2008 "Server Explorer" panel. I downloaded Npgsql but as I understand that's only a library for the code itself, not the Server Explorer. ...