Skip site navigation (1) Skip section navigation (2)

[Fwd: inserting integer in Table]

From: Thomas SMETS <tsmets(at)altern(dot)org>
To: psql Admin <pgsql-admin(at)postgresql(dot)org>, psql novice <pgsql-novice(at)postgresql(dot)org>, psql sql <pgsql-sql(at)postgresql(dot)org>
Subject: [Fwd: inserting integer in Table]
Date: 2000-07-25 02:02:36
Message-ID: 397CF53C.57790566@altern.org (view raw or flat)
Thread:
Lists: pgsql-adminpgsql-novicepgsql-sql
 
> 
> In PostgreSQL table is :
> <snip>
> test=> \d  test_blob_s;
> Table    = test_blob_s
> +----------------------------------+----------------------------------+-------+
> |              Field               |              Type                |
> Length|
> +----------------------------------+----------------------------------+-------+
> | filenumber                       | int4
> |     4 |
> | filename                         | varchar()
> |   100 |
> | filecontent                      | oid
> |     4 |
> +----------------------------------+----------------------------------+-------+
> test=>
> </snip>
> 
> Now I'm willing to insert in that table rows like this one :
> <i>, <file_name_i>, <file_name_i_content>.
> 
> Here's is the (not-so-running) code :
> 
> <snip>
> #
> #
> # ############################################
> import os, glob
> from pg import DB
> 
> conn=DB('test')
> conn.query("BEGIN WORK;")
> 
> i = 0
> for name in glob.glob("*.jpg"):
>     print "Name is ", name,
>     try:
>         conn.query("insert into test_blob_s  filenumber  values (" + i +
> ")")
>         print " inserted"
>     except TypeError,e:
>             print '\nerror ', e, 'undefined'
> #    conn.query( "update test_blob_s set filename = '" + name + "')")
> #    conn.query( "update test_blob_s set filecontent = '" +
> lo_import(name) + "')")
> 
>     i = i + 1
> 
> conn.query(" COMMIT WORK;");
> 
> </snip>
> 
> of course I can't have it passing the insert of "i"
> Could some one help ?
> 
> Thomas,

-- 

Thomas SMETS                           Phone : +32 (0)2 742. 05. 94.
Av. de la Brabançonne 133 / 3          e-mail : tsmets @altern.org
1030 Bruxelles

==== Quote of the day =========
You shouldn't wallow in self-pity.  But it's OK to put your feet in it
and swish them around a little.
		-- Guindon
 ======= End of Quote =========

pgsql-novice by date

Next:From: Tom LaneDate: 2000-07-25 05:44:37
Subject: Re: 4 billion record limit?
Previous:From: Joseph ShraibmanDate: 2000-07-25 01:10:58
Subject: Re: 4 billion record limit?

pgsql-admin by date

Next:From: miguel valeroDate: 2000-07-25 21:14:09
Subject: Report generator
Previous:From: John BurskiDate: 2000-07-22 14:16:43
Subject: Re: [NOVICE] pg_dump problem

pgsql-sql by date

Next:From: Jerome RaupachDate: 2000-07-25 16:28:39
Subject: command in C++
Previous:From: Zot O'ConnorDate: 2000-07-24 23:09:50
Subject: Views on Unions

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group