postgresql

Switching Django project from sqlite3 backend to postgresql failes when loading datadump

I am currently using sqlite3 as the DB for one of my Django projects. I want to change this to use postgresql, and I would like to keep all the data intact. I used ./manage.py dumpdata > dump.json to create a dump of the data, and changed my settings to use postgresql. Trying first with an empty database to do ./manage.py loaddata dump....

Is there a mature way to interface Erlang and PostgreSQL or MySQL?

I have searched the internet for drivers to connect to either database and all the projects I have seen have either been dead for a long time, look incomplete, or don't have good enough documentation to be usable without reading all the source. Has anyone used Erlang to talk to either MySQL or PostgreSQL before and what sort of package ...

postgresql db structure script

How to get my db structure without the data, (schema, tables, ...) as a script by command line. ...

how to display image blob from postgres to VB 6

I have applicatin in VB 6 and i ask if i can to display image blob from postgres to VB 6 ...

JdbcTemplate and inet data type

One of my table has the column type as inet. And when I try to perform insert operation using String as the type for inet column, it's saying "column "ip" is of type inet but expression is of type character varying:", which is perfectly valid exception. Now, my question is how do I instruct jdbcTemplate to use inet type instead of Strin...

question regarding postgresql sequences

Hi guys, I have a question regarding postgresql sequences. For instance, for bigserial datatype, is it true that the sequence is advanced, then the number is retrieved and even if the insertion/committing is not successful, the sequence doesn't backtracks. Which means the next time I might be doing insertion to the table, that might be...

postgresql: Is it possible to dynamically loop through a table's column

Hi, I have a trigger function for a table test which has the following code snippet - IF TG_OP='UPDATE' THEN IF OLD.locked > 0 AND ( OLD.org_id <> NEW.org_id OR OLD.document_code <> NEW.document_code OR -- Other columns .......................... ) THEN RAISE EXCEPTION 'Message'; /* R...

How to access Postgres data from SQL Server (linked servers)

I have the following situation: DB Server 1 is Sql Server 2008 and hosts database A with transaction records DB Server 2 is Postgres and hosts database B with records of prices Server2 is added as a linked server to server1. I need to run a query where for each transaction record on server1 I need to check a number of prices from serv...

Error : operator does not exist: dom_id = character varying at character 65 In Postgres SQL

Hey All, I am trying one stored procedure as follows. CREATE OR REPLACE FUNCTION "public"."get_fees" (VARCHAR(5000)) RETURNS text[] AS $body$ DECLARE student_ids ALIAS FOR $1; studetFee text[]; BEGIN FOR studetFee IN SELECT * FROM Student_fee WHERE student_id IN ( student_ids::VARCHAR(5000) ) LOOP **** some *** END LOOP; END; $b...

python postgres

Hi i want to store null value in a column.The column is nullable.The column value is not null always it depends on certain conditions.I dont want to write two queries in this case.I have tried None,null both but it gives me error saying worng type for double precision ...

How do I ALTER a set of partitioned tables in Postgres?

I created a set of partitioned tables in Postgres, and started inserting a lot of rows via the master table. When the load process blew up on me, I realized I should have declared the id row BIGSERIAL (BIGINT with a sequence, behind the scenes), but inadvertently set it as SERIAL (INTEGER). Now that I have a couple of billion rows loaded...

Randomize database row results

I've been finding some unit tests that assume that the results of database queries are in a particular order, yet the query being run doesn't include an order by clause. I would like to find more of these unit tests, so that I can examine whether the test is at fault in its assumptions, or the code is at fault in its lack of specifying ...

Is it possible to store a 1 byte number in Postgres?

I have 7 8-bit integer values per record that I want to store in Postgres. Pg doesn't offer a single byte integer type, SMALLINT, or 2 bytes, being the smallest integer datatype. Is there anyway I can store my 7 8-bit numbers and save on space? Would an array type with a 7 element array be more compact? Or, should I make a binary repres...

How to do 'grading' in pure (i.e. ANSI) SQL

I have a table that looks something like this: CREATE TABLE student_results(id integer, name varchar(32), score float); Lets make the following two assumptions: assume that the score goes from 0 to a maximum of 100. assume that I want to grade students in 'step sizes' of 10 so I want to apply the following grading: Score Gra...

Drop ALL triggers from Postgres DB?

Is there any way to drop ALL triggers from ALL tables in Postgres? I know there's a pg_trigger table I could look at, but it doesn't look like it contains enough information for me to decipher which triggers I have added to my tables. It also looks like Foreign Key constraints show up in the pg_trigger table, which I DO NOT want to drop...

Most compact and fastest way to store my string in PostgreSQL

I have a large hexidecimal (16 byte, 32 hex digits) data item that always has the format: 00d980113901429fa6de7fb7e2da705a This is coming in as an ASCII string from my source (i.e., the zero above is character zero 0x30, not 0x00), and I would like to know peoples' opinions on the best way (irt storage and speed) to store this in Post...

Postgresql case and testing boolean fields

Hello to all. First: I'm running postgresql 8.2 and testing my queries on pgAdmin. I have a table with some fields, say: mytable( id integer, mycheck boolean, someText varchar(200)); Now, I want a query similary to this: select id, case when mycheck then (select name from tableA) else (select name from tableB) end ...

Rspec Postgres Error

Let me preface this be saying that I'm newb to both TDD and Ruby on Rails. I'm using Rspec to perform unit testing of my data layer and to ensure that my database is rejecting invalid input. My rspec code looks as follows: it "should fail at saving without name" do @my_data.attributes = valid_my_data_attributes.except(:name) @my_d...

How to set an object to null

Hi, How to set an object to null. Ex: my object samp contains three fileds samp.field1,samp.field2.sampfield3 If i set samp:= null; im getting errors is there a way to set the object value to null. ...

PostgreSQL slow on a large table with arrays and lots of updates

I have a pretty large table (20 mln records) which has a 3 column index and an array column. The array column is updated daily (by appending new values). There is also inserts, but not as much as updates. The data in the array represents daily measurements corresponding to the three keys, something like this: [[date_id_1, my_value_for_d...