Skip to content

Command line tool for uploading one or more DBs to Now #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
simonw opened this issue Oct 24, 2017 · 3 comments
Closed

Command line tool for uploading one or more DBs to Now #26

simonw opened this issue Oct 24, 2017 · 3 comments

Comments

@simonw
Copy link
Owner

simonw commented Oct 24, 2017

Uploading files appears to be undocumented, but I found it in their code here: https://github.com/zeit/now-cli/blob/0ca7d1fe44ebdf460b64fdc38ba543b8e295ac40/src/providers/sh/util/index.js#L291

@simonw simonw added this to the v1 stretch goals milestone Oct 24, 2017
@simonw simonw modified the milestones: v1 stretch goals, Ship v1 Nov 10, 2017
@simonw simonw added the large label Nov 10, 2017
@simonw simonw changed the title Command line tool for uploading a DB to Now Command line tool for uploading one or more DBs to Now Nov 11, 2017
@simonw
Copy link
Owner Author

simonw commented Nov 11, 2017

Simplest version of this:

  1. Create a temporary directory
  2. Write a Dockerfile into it that pulls an image and pip installs datasette
  3. Add symlinks to the DBs they listed (so we don't have to copy them)
  4. Shell out to "now"
  5. Done!

@simonw
Copy link
Owner Author

simonw commented Nov 11, 2017

Doing this works:

import os
os.link('/tmp/databases/northwind.db', '/tmp/tmp-blah/northwind.db')

That creates a link in tmp-blah - and then when I delete that entire directory like so:

import shutil
shutil.rmtree('/tmp/tmp-blah')

The original database is not deleted, just the link.

@simonw
Copy link
Owner Author

simonw commented Nov 11, 2017

I can create the temporary directory like so:

import tempfile
t = tempfile.TemporaryDirectory()
t
<TemporaryDirectory '/var/folders/w9/0xm39tk94ng9h52g06z4b54c0000gp/T/tmpkym70wlp'>
t.name
'/var/folders/w9/0xm39tk94ng9h52g06z4b54c0000gp/T/tmpkym70wlp'

And then to delete it all:

t.cleanup()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant