How to Load SQL File to Database

published at 20 Feb, 2010 by Szymon LipiƄski tags: database

It would be nice to have the possibility of loading an sql file to database using a normal database api. OK, let’s define what the ‘normal api’ is. This should be a full featured api for connecting to database and performing queries, with many drivers available. My favorite ones are: JDBC and DBI (yes, the one from Perl). Unfortunately Python doesn’t have any. Python’s DBAPI 2.0 is a kind of joke, not API.

Another problem is that there isn’t any way to load an sql file into the database. The only workaround that I found is to use an external program like: psql < file.sql. But this is not the way an API should work.