python + postgres psql + os.popen
Bruno Desthuilliers
onurb at xiludom.gro
Thu Jun 22 04:00:57 EDT 2006
damacy wrote:
> hello, everyone.
>
> i am trying to write a program which executes SQL commands stored in
> .sql files.
>
> i wrote a function called psql() whose contents look like the
> following.
>
> ...
> os.popen(command)
> file = os.popen(command, 'w')
> file.write(password)
> file.close()
> ...
>
> where command looks like
> psql -h [host] -d [dbname] -U [username] -W -f "[filename]"
>
> this works well.
But is a very strange way to access a RDBMS from Python code. Are you
aware of the existence of db modules ?
> can anyone help me?
http://www.python.org/dev/peps/pep-0249/
http://initd.org/projects/psycopg1
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"
More information about the Python-list
mailing list