how to pipe to variable of a "here document"

E

eight02645999

hi

I need to execute sql command using a "here document" like in unix.

os.popen("osql", "w").write("""\
select * from table
go
""")

how can i pipe these result of the select into a variable?
thanks
 
B

Burton Samograd

I need to execute sql command using a "here document" like in unix.

os.popen("osql", "w").write("""\
select * from table
go
""")

how can i pipe these result of the select into a variable?

popen doesn't work that way. you can only open them read or write.
you'll have to create a couple of pipes (one for reading, one for
writing), do a fork, execve, etc with the posix api. at least that's
how one does it in C...i'm a bit new to python so there might be
better ways.
 
D

Dennis Lee Bieber

popen doesn't work that way. you can only open them read or write.
you'll have to create a couple of pipes (one for reading, one for
writing), do a fork, execve, etc with the posix api. at least that's
how one does it in C...i'm a bit new to python so there might be
better ways.

I missed this the first time through...

Question: Is there a DB-API module that can directly connect to the
database server?

Interim: Check the variations of the popen family, or for Python 2.4
(2.3 if you download the separate module) the subprocess module. There
are variations that allow for both stdin and stdout connections.
--
 
L

Lawrence D'Oliveiro

Dennis Lee Bieber said:
Question: Is there a DB-API module that can directly connect to the
database server?

There certainly is for MySQL, which is what I mostly use.
 
D

Dennis Lee Bieber

There certainly is for MySQL, which is what I mostly use.

There is for many: PostgreSQL, MySQL, Firebird/Interbase... But is
"osql" an Oracle command line program -- so an Oracle db-api would be
needed, no?
--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top