question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

See if I can get Datasette working on Zeit Now v2

See original GitHub issue

I thought this was impossible because AWS Lambda doesn’t ship the sqlite3 standard library module… but apparenttly that’s not the case on Now v2 any more!

https://now-2-python-versions-ks69olzpi.now.sh/api

 _________________________________________________________________________________________________________________________________________________________________ 
/ Hello from Python from a ZEIT Now Serverless Function! Version is 3.6.10 (default, Mar 10 2020, 22:54:43)                                                       \
\ [GCC 4.8.3 20140911 (Red Hat 4.8.3-9)], sqlite3 module = <module 'sqlite3' from '/var/lang/lib/python3.6/sqlite3/__init__.py'>, sqlite3 version = [('3.7.17',)] /
 ----------------------------------------------------------------------------------------------------------------------------------------------------------------- 
     \   ^__^
      \  (oo)\_______
         (__)\       )\/\
           ||----w |
           ||     ||

That’s from shipping this code as api/index.py:

from http.server import BaseHTTPRequestHandler
from cowpy import cow
import sys


try:
    import sqlite3
except ImportError:
    sqlite3 = None


class handler(BaseHTTPRequestHandler):
    def do_GET(self):
        self.send_response(200)
        self.send_header("Content-type", "text/plain")
        self.end_headers()
        message = cow.Cowacter().milk(
            "Hello from Python from a ZEIT Now Serverless Function! Version is {}, sqlite3 module = {}, sqlite3 version = {}".format(
                sys.version, sqlite3, sqlite3.connect(":memory:").execute("select sqlite_version()").fetchall()
            )
        )
        self.wfile.write(message.encode())
        return

Now v2 supports ASGI so this might be possible without too much work: https://zeit.co/docs/runtimes#advanced-usage/advanced-python-usage/asynchronous-server-gateway-interface

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
simonwcommented, Apr 6, 2020

I’m confident it’s possible to create a plugin that deploys to Now v2 now. I’ll do the rest of the work in a separate repo: https://github.com/simonw/datasette-publish-now

0reactions
simonwcommented, Apr 6, 2020

Yes I think that’s it - I created a table in about.db, then dropped that table and ran vacuum and the result was an empty database file that wasn’t zero bytes. I deployed it and it worked: https://datasette-koo7abu7j.now.sh/

Read more comments on GitHub >

github_iconTop Results From Across the Web

Simon Willison on Twitter: "Zeit Now v2 is a totally different ...
See if I can get Datasette working on Zeit Now v2 · Issue #717 · simonw/datasette. I thought this was impossible because AWS...
Read more >
Goodbye Zeit Now v1, hello datasette-publish-now—and ...
So Datasette on Now v2 just wasn't going to work. ... I figured it would be responsible to double-check and make sure that...
Read more >
Datasette News
Datasette Lite is a new way to run Datasette: entirely in your browser, thanks to the Pyodide project which provides a full Python...
Read more >
Changelog - Datasette documentation
Changelog#. 0.63.2 (2022-11-18)#. Fixed a bug in datasette publish heroku where deployments failed due to an older version of Python being requested.
Read more >
Datasette Documentation
datasette -render-images works with SQLite tables that contain binary ... You can then sort by this distance to find records closest to a ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found