0

I am looking for a way to take results from an SQLite database, select part of the schema, and recreate this on a remote machine via paramiko without the intermediate step of a local file or any form of remote file that is not a pure SQLite database.

This blog post sets up a nice way to potential get the part of the schema I want but I would have to dump this to a file then read it into the database via a remote script afterwards:

http://blog.marcus-brinkmann.de/2010/08/27/how-to-use-sqlites-backup-in-python/

I know paramiko can provide remote file like objects like this:

f = self.sftp.open(path, 'wb')
f.write(fileobj.read())
f.close()

Is there any way to combine some file object, StringIO, or byte conversion with one of the SQLite DB APIs in order to provide a way to stream a prebuilt SQLite database without extra file writes on the host or remote?

In other words something like this:

f = self.sftp.open(path, 'wb')
conn = sqlite3.connection(f)

1 Answer 1

1

Not a direct solution to your problem, but this is what a web api is for. Building a REST-like api is probably a good bet.

Since you are already in python, I would take a look at Django which can provide a drop-ship API using django-tastypie. Django will be a less desireable solution if you are operating with an already existing database schema, although you can make it work.

You may also want to look into Pylons, which is a more generic/barebones framework than Django. All depends on what your actual requirements are.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.