Read SQL with Python

At first make sure you have the PyPi package poster installed. On Ubuntu you can install it in the terminal like this:

apt-get install python-poster

Create a Python file with the following code to read your SQL file. Don't forget to replace the example file paths with the actual ones.

from poster.encode import multipart_encode
from poster.streaminghttp import register_openers
import urllib2

# Register the streaming http handlers with urllib2

# Use multipart encoding for the input files
datagen, headers = multipart_encode({ 'files[]': open('file.sql', 'rb')})

# Create the request object
request = urllib2.Request('', datagen, headers)

# Do the request and get the response
# Here the SQL file gets converted to CSV
response = urllib2.urlopen(request)

# Check if an error came back
if'Content-Type') == 'application/json':

# Write the response to /tmp/
with open('/tmp/', 'wb') as local_file:

print 'Conversion result successfully written to /tmp/!'

After running the command, try to open /tmp/ The archive contains CSV files that you can read easily with Python.

How does it work?

The RebaseData PHP-Client internally uses our API to convert the .SQL file to a standardized format. Then you can read the data using PHP as shown above.

Why use RebaseData?