See if I can get Datasette working on Zeit Now v2
See original GitHub issueI 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:
- Created 3 years ago
- Reactions:1
- Comments:10 (10 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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
Yes I think that’s it - I created a table in
about.db
, then dropped that table and ranvacuum
and the result was an empty database file that wasn’t zero bytes. I deployed it and it worked: https://datasette-koo7abu7j.now.sh/