-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Publish SQLite database using Datasette
Showing
6 changed files
with
97 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import asyncio | ||
import logging | ||
from pathlib import Path | ||
|
||
import uvicorn | ||
from datasette.app import Datasette | ||
from datasette.cli import check_databases | ||
from datasette.utils import SpatialiteNotFound, StartupError | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
here = Path(__file__).parent | ||
|
||
|
||
def main(): | ||
#datasette.cli.serve() | ||
|
||
files = ["phenodata-dwd-annual-recent.sqlite"] | ||
options = {"config_dir": here} | ||
#print("options:", options) | ||
#scsdc | ||
|
||
try: | ||
ds = Datasette(files, **options) | ||
except SpatialiteNotFound: | ||
raise IOError("Could not find SpatiaLite extension") | ||
except StartupError as e: | ||
raise IOError(e.args[0]) | ||
|
||
# Run the "startup" plugin hooks | ||
asyncio.get_event_loop().run_until_complete(ds.invoke_startup()) | ||
|
||
# Run async soundness checks - but only if we're not under pytest | ||
asyncio.get_event_loop().run_until_complete(check_databases(ds)) | ||
|
||
url = None | ||
host = "localhost" | ||
port = 7777 | ||
|
||
# Start the server | ||
url = "http://{}:{}{}?token={}".format( | ||
host, port, ds.urls.path("-/auth-token"), ds._root_token | ||
) | ||
logger.info(url) | ||
uvicorn_kwargs = dict( | ||
host=host, port=port, log_level="info", lifespan="on", workers=1 | ||
) | ||
|
||
# Bind to a Unix domain socket | ||
#if uds: | ||
# uvicorn_kwargs["uds"] = uds | ||
uvicorn.run(ds.app(), **uvicorn_kwargs) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"cache_size_kb": 50000, | ||
"default_cache_ttl": 86400, | ||
"facet_time_limit_ms": 1000, | ||
"force_https_urls": false, | ||
"max_csv_mb": 500, | ||
"num_sql_threads": 10, | ||
"sql_time_limit_ms": 7420 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters