trianIMDB
trianIMDB

Reputation: 1

Using imdbpy2sql.py to populate PostgreSQL

I'm trying to use imdbpy2sql.py documented at http://imdbpy.sourceforge.net/docs/README.sqldb.txt but I am having trouble with syntax & directories. To simplify things I loaded the IMDb files in a subdirectory of "C:\Users\dom\AppData\Roaming\Python\Scripts" eg: "C:\Users\dom\AppData\Roaming\Python\Scripts\imdb"

Then I executed: os.chdir("C:\Users\dom\AppData\Roaming\Python\Scripts")

I tried to use a PostgreSQL database with variations of the following command and got:

imdbpy2sql.py -d /imdb -u 'postgres://sid:asdf@host/imdb'

File "", line 1 imdbpy2sql.py -d /imdb -u 'postgres://sid:asdf@host/imdb' ^ SyntaxError: invalid syntax

In a last grasp effort I tried M$ SQL server and had a similar error:

>>> imdbpy2sql.py -d /imdb -u mssql://dom:@localhost/imdb

File "", line 1 imdbpy2sql.py -d /imdb -u mssql://dom:@localhost/imdb ^ SyntaxError: invalid syntax

Tips on syntax would be much appreciated!

Upvotes: 0

Views: 1575

Answers (1)

Craig Ringer
Craig Ringer

Reputation: 324455

imdbpy2sql.py -d /imdb -u 'postgres://sid:asdf@host/imdb'

is a command prompt command invocation, not Python code. You cannot run it from a Python command prompt.

You would need to open cmd.exe (on Windows) and run something along the lines of:

c:
cd \Users\dom\AppData\Roaming\Python\Scripts
python imdbpy2sql.py -d /imdb -u 'postgres://sid:asdf@host/imdb'

If you wanted to fire it off from within a Python interpreter you could do so by using subprocess.check_call or os.system.

Additionally, the leading slash on /imdb will cause Python to think you mean \imdb, ie "the directory named imdb in the root of this drive, so it'll complain it can't find c:\imdb. You probably want to just say imdb without the slash.

Upvotes: 1

Related Questions