psycopg simplest problem

Glauco 00515879256 at fastwebnet.it
Fri Jul 8 10:23:50 EDT 2005


I'm rebuilding my old library i've done some year ago using python and 
postgres.

My problem is to do a middle layer over pycopg for eliminate type 
casting problem in postgres in all direction.

i've resolved this doing a C extension in python and manipulating only 
string and int in my application.

this is my example:
import sqlvar

sql = """insert into mytable (myint, mytext, maydate)
          values
          (%d,%s,%s);""" % (sqlvar.number(myvalue1), 
sqlvar.text(myvalue2), sqlvar.date(myvalue3) )

all problem concerning quoting, " ' -> ''", null, None, 0, empty string 
is solved by the sqlvar lib.


I want to eliminate this problem forever, i want to manipulate only 
correct type as DateTime obj in my application so i want to arrive at 
this solution:


sql = """insert into mytable (myint, mytext, maydate)
          values
          (%s,%s,%s);""" % (myvalue1, myvalue2, myvalue3)

without all time check for none, empty string and so on...

I've seen API of psycopg and some procedure for the solution but all are 
    too spaghetti for me.

I'm only with this problem ?


Glauco


-- 

                          \\\|///
                        \\  - -  //
                         (  @ @  )
+---------------------oOOo-( )-oOOo--------------------------+
|                                                            |
| I have a dream that one day this nation will rise up and   |
|   live out the true meaning of its creed: "We hold these   |
|   truths to be self-evident:that all men are created equal.|
| I have a dream that one day on the red hills of Georgia    |
|   the sons of former slaves and the sons of former         |
|   slaveowners will be able to sit down together at a table |
|   of brotherhood.                                          |
| I have a dream that one day even the state of Mississippi, |
|   a desert state, sweltering with the heat of injustice    |
|   and oppression, will be transformed into an oasis of     |
|   freedom and justice.                                     |
| I have a dream that my four children will one day live in  |
|   a nation where they will not be judged by the color of   |
|   their skin but by the content of their character.        |
| I have a dream today.                                      |
|                                                            |
|                        Martin Luther King, Jr  28 Ago 1963 |
+------------------------------------------------------------+
|                    glauco(at)uriland.it                    |
|  www.uriland.it      .oooO                ICQ: 115323690   |
+--------------------- (   )------ Oooo.---------------------+
                         \ (        (   )
                          \_)        ) /
                                    (_/



More information about the Python-list mailing list