Monika Jisswel wrote:
Hi everyone,
In my program I have this code :
self.run_cmd_0 = subprocess.Popen(self.cmd_0, stdout =
subprocess.PIPE, shell = True) #(1)
self.run_cmd_1 = subprocess.Popen(self.TOCOL, stdin =
self.run_cmd_0.stdout, stdout = subprocess.PIPE, shell = True) #(2)
self.result_0 =
StringIO.StringIO(self.run_cmd_1.communicate()[0]) #(3)
(1) : executes cmd_0 as a subprocess with stdout to PIPE
(2) : executes cmd_1 a second process with stdin from the previouse cmd_0
(3) : Here I tried to use StringIO module to create a file object from
stdout of cmd_1 : I need a file object because I have a mysql query
later in my program to load it into the database :
self.cmd_sql_2 = "load data local infile '%s' into table
statistics fields terminated by '\t' lines terminated by '\n'" %
self.FILE
so self.cur.execute(self.cmd_sql_2) fails.
the problem is that mysql is expecting a REAL file for this query !!
is there any pythonic way of avoiding to write to disk before loading
into Mysql database ? some sort of in-memory file oject.
I don't think there is a pure Pythonic way. Have you considered using a
RamDisk? http://en.wikipedia.org/wiki/RAM_disk for general details.
http://www.codeguru.com/cpp/w-p/system/devicedriverdevelopment/article.php/c5789/
for a Windows Ram Disk driver installer. I just tried it - it works like
a charm.
HTH.
--
Bob Gailer
919-636-4239 Chapel Hill, NC
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor