[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
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-novice pgsql-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 =========

Browse pgsql-admin by date

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

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2000-07-25 05:44:37 Re: 4 billion record limit?
Previous Message Joseph Shraibman 2000-07-25 01:10:58 Re: 4 billion record limit?

Browse pgsql-sql by date

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