help with postgres and csv:
i solved my problem by playing with the sql line a little.
it looked like this : sql  = " UPDATE hotel SET path_picture =
"+"';"+hotel_url+"'
 WHERE code LIKE '"+"%"+hotel_code+"'"
 now it's like this : " UPDATE hotel SET path_picture = '" + hot_url + "'
WHERE code LIKE '%" + hot_code + "';"

i guess the problem was in building the sql string, but i don't yet quite
understand what i did.can someone point me to some online resorces about
postgres and python integration?as i see it, python and postgresql are a
quite powerful combination, when done properly.i would like to learn more
about this, and would appreciate some pointing in the right direction.


On Tue, Sep 3, 2013 at 4:35 AM, <tutor-requ...@python.org> wrote:

> Send Tutor mailing list submissions to
>         tutor@python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         http://mail.python.org/mailman/listinfo/tutor
> or, via email, send a message with subject or body 'help' to
>         tutor-requ...@python.org
>
> You can reach the person managing the list at
>         tutor-ow...@python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Tutor digest..."
>
>
> Today's Topics:
>
>    1. os.system vs subprocess.Popen args problems (learner404)
>    2. Re: os.system vs subprocess.Popen args problems (Oscar Benjamin)
>    3. help with postgreSQL and .csv (Ismar Sehic)
>    4. Using tkinter for cross platform application (Max Bedacht)
>    5. Re: help with postgreSQL and .csv (R. Alan Monroe)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 2 Sep 2013 16:19:17 +0200
> From: learner404 <learner...@gmail.com>
> To: Tutor Python <tutor@python.org>
> Subject: [Tutor] os.system vs subprocess.Popen args problems
> Message-ID:
>         <CAKib=N5QV4YP0eN8rsw4_HtHr0QEunqF=
> oaozuvrgth1ru-...@mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hello,
>
> I can't understand why the command below works with os.system but not with
>  subprocess.Popen (on windows, recording video with FFMPEG.exe)
>
> cmd=('ffmpeg -f dshow -i video="%s" -f dshow -i audio="%s" -q 5
> "%s"')%(videoinputName, audioinputName, videoFileOutput)
> os.system(cmd)
> *works*
>
>
> subprocess.Popen(["ffmpeg","-f","dshow","-i",'video="%s"'%videoinputName,"-f","dshow","-i",'audio="%s"'%audioinputName,"-q","5","%s"%videoFileOutput])
> *don't work*
> >> [dshow @ 025984a0] Could not find video device.
> >> video="QuickCam Orbit/Sphere AF": Input/output error
>
> The reason I'm going with subprocess is to avoid to have the DOS window
> coming in the forefront.
> Any idea of what I'm doing wrong? Or any other way to hide or minimize the
> DOS window?
>
> Thanks.
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.python.org/pipermail/tutor/attachments/20130902/8e44abe0/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 2
> Date: Mon, 2 Sep 2013 15:44:25 +0100
> From: Oscar Benjamin <oscar.j.benja...@gmail.com>
> To: learner404 <learner...@gmail.com>
> Cc: Tutor Python <tutor@python.org>
> Subject: Re: [Tutor] os.system vs subprocess.Popen args problems
> Message-ID:
>         <CAHVvXxT3kYEHBNgKkVsrGm=
> ky5zt7db+p5ofb4erlpcmbmg...@mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On 2 September 2013 15:19, learner404 <learner...@gmail.com> wrote:
> > Hello,
> >
> > I can't understand why the command below works with os.system but not
> with
> > subprocess.Popen (on windows, recording video with FFMPEG.exe)
> >
> > cmd=('ffmpeg -f dshow -i video="%s" -f dshow -i audio="%s" -q 5
> > "%s"')%(videoinputName, audioinputName, videoFileOutput)
> > os.system(cmd)
> > *works*
> >
> >
> subprocess.Popen(["ffmpeg","-f","dshow","-i",'video="%s"'%videoinputName,"-f","dshow","-i",'audio="%s"'%audioinputName,"-q","5","%s"%videoFileOutput])
>
> I think you need additional quotes for the videoFileOutput part e.g.
>
> '"%s"' % videoFileOutput
>
> > *don't work*
> >>> [dshow @ 025984a0] Could not find video device.
> >>> video="QuickCam Orbit/Sphere AF": Input/output error
>
> I see that video has spaces in it. You'd think it was unnecessary to
> have those quotes since you've already split the command string into a
> list of strings. Unfortunately Windows has a fairly arcane way of
> handling arguments to subprocesses and Python tries to emulate that:
>
> http://docs.python.org/2/library/subprocess.html#converting-an-argument-sequence-to-a-string-on-windows
>
> > The reason I'm going with subprocess is to avoid to have the DOS window
> > coming in the forefront.
> > Any idea of what I'm doing wrong? Or any other way to hide or minimize
> the
> > DOS window?
>
> Another thing is that you shouldn't use Popen directly unless you're
> doing something fancy (which you're not if os.system does what you
> want). Use subprocess.check_call instead:
>
>
> subprocess.check_call(["ffmpeg","-f","dshow","-i",'video="%s"'%videoinputName,"-f","dshow","-i",'audio="%s"'%audioinputName,"-q","5",'"%s"'%videoFileOutput])
>
>
> Oscar
>
>
> ------------------------------
>
> Message: 3
> Date: Mon, 2 Sep 2013 23:22:00 +0200
> From: Ismar Sehic <i.she...@gmail.com>
> To: tutor@python.org
> Subject: [Tutor] help with postgreSQL and .csv
> Message-ID:
>         <CA+hLDguwkAhPJN8pfvduSPi96VbF1kj_ggP5P=YijHHB=
> sy...@mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> hello.
> i wrote the following code, to insert some values from a csv file to my
> postgres table :
>
> *    ******
> *import psycopg2*
> *conn = psycopg2.connect("host = ***.***.***.*** user=******* dbname =
> ****** ")*
> *cur = conn.cursor()*
> *import csv*
> *with open('HotelImages.csv', 'rb') as f:           *
> *    mycsv = csv.reader(f, delimiter = '|')*
> *    for row in mycsv:*
> *        hotel_code = row[0]*
> *        hotel_url = row[-1]*
> *        sql  = " UPDATE hotel SET path_picture = "+"';"+hotel_url+"'
>  WHERE code LIKE '"+"%"+hotel_code+"'"*
> *        print '--->'+sql*
> *        cur.execute(sql)*
> *        conn.commit()*
> *c.close()*
> *print '----->Complete'*
> *    *******
>
>
> the for loop iterates through the table, comparing the values from the csv
> line by line with the table column 'code'.
> example of csv lines:
> *    ******
> *94176|HAB|7|2|09/094176/094176a_hb_w_007.jpg*
> *94176|HAB|8|3|09/094176/094176a_hb_w_008.jpg*
> *94176|BAR|6|7|09/094176/094176a_hb_ba_006.jpg*
> *94176|RES|5|6|09/094176/094176a_hb_r_005.jpg*
> *94176|HAB|1|1|09/094176/094176a_hb_w_001.jpg*
> *94176|CON|4|8|09/094176/094176a_hb_k_004.jpg*
> *94176|COM|2|4|09/094176/094176a_hb_l_002.jpg*
> *94176|RES|3|5|09/094176/094176a_hb_r_003.jpg*
> *    ******
> example of the code column value : *GEN94176, XLK94176,KJK94176*....
> the number before the first ' | ' gets just one hit in the database table
> column, inserts some random picture once.also, if the same numbers in some
> other 'code' column row are appearing, but in different order, it inserts
> the same picture.
> my goal is to make it write all the picture url values separated by a ';'
> in just one field and to input the data correctly.
> i'm new to python, as a matter of fact, just started to learn programming.
> i would really like to know where is my mistake.advice and help
> appreciated!
>
> Thanks.
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.python.org/pipermail/tutor/attachments/20130902/a571b765/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 4
> Date: Mon, 2 Sep 2013 22:32:33 -0300
> From: Max Bedacht <bedac...@gmail.com>
> To: tutor@python.org
> Subject: [Tutor] Using tkinter for cross platform application
> Message-ID:
>         <CAAZ6rGWMUOEr908pBp-C1BewSBCnGU=
> jyqcaxay5xc6_0po...@mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hello;
> I'm looking for a quick, if possible, solution to a problem I'm having. I
> have developed an application which I'm packaging to run on Windows, Linux
> and eventually OS-X. I have gone through myriad iterations, bouncing
> between Python 2.7 and 3.3 and between 32 and 64 bit Linux, Windows XP and
> Windows 8. At this point I can happily say that everything is working on
> all platforms except Apple, which I can not test at this time.
>
> The problem that I am now trying to resolve, which I hope is the last one,
> is the following:
>
> When running a packaged 'compiled' version on all windows platforms the
> screen, while complete, is reduced by about 20% from the Linux version,
> where the development was mostly done. Images seem all to be the same size,
> as is the main window, but all of the text, labels and buttons are reduced
> in size, not by much, but enough to be annoying. (Curiously, this size
> difference does not happen in my development environment (Eclipse/PyDev).
> There, if anything, the text in windows seems to be a bit larger than that
> in Linux).
>
> I seem to have 3 options at this point:
>
>
>    1. live with it;
>    2. adjust the image portion, which seems fixed in size, to be x% smaller
>    in the Windows environment, making the overall window smaller but
>    maintaining proportionality;
>    3. see if there is a magic bullet to resolve this issue.
>
> Any thoughts would be greatly appreciated.
>
> (Ubuntu 13.04 (64bit), Lubuntu 13.04(32Bit), Windows 8(64Bit), Windows
> 7(64Bit), Windows XP
> Python 2.7 and 3.3 64Bit on the Ubuntu box.
> Python 2.7 and 3.3 32Bit on the Windows boxes
>
> Thanks;
> Max Bedacht
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.python.org/pipermail/tutor/attachments/20130902/f104ada1/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 5
> Date: Mon, 2 Sep 2013 22:35:46 -0400
> From: "R. Alan Monroe" <amon...@columbus.rr.com>
> To: tutor@python.org
> Subject: Re: [Tutor] help with postgreSQL and .csv
> Message-ID: <16110070470.20130902223...@columbus.rr.com>
> Content-Type: text/plain; charset=iso-8859-1
>
> > my goal is to make it write all the picture url values separated by
> > a ';' in just one field and to input the data correctly. ?
>
> I haven't used postgresql much. Could it be you're just missing
> path_picture as part of your data value? i.e.
>
> UPDATE hotel SET path_picture = + hotel_url
> UPDATE hotel SET path_picture = path_picture + hotel_url
>
> Alternatively, you could read the entire csv file and generate the
> semicolon-separated strings as dictionary entries, then as a second
> step, insert all those dictionary entries into the database.
>
> Alan
>
>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
> ------------------------------
>
> End of Tutor Digest, Vol 115, Issue 6
> *************************************
>
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to