{"ok": true, "next": null, "rows": [{"id": "internals:datasette-add-database", "page": "internals", "ref": "datasette-add-database", "title": ".add_database(db, name=None, route=None)", "content": "db  - datasette.database.Database instance \n                         \n                             The database to be attached. \n                         \n                     \n                     \n                         name  - string, optional \n                         \n                             The name to be used for this database . If not specified Datasette will pick one based on the filename or memory name. \n                         \n                     \n                     \n                         route  - string, optional \n                         \n                             This will be used in the URL path. If not specified, it will default to the same thing as the  name . \n                         \n                     \n                 \n                 The  datasette.add_database(db)  method lets you add a new database to the current Datasette instance. \n                 The  db  parameter should be an instance of the  datasette.database.Database  class. For example: \n                 from datasette.database import Database\n\ndatasette.add_database(\n    Database(\n        datasette,\n        path=\"path/to/my-new-database.db\",\n    )\n) \n                 This will add a mutable database and serve it at  /my-new-database . \n                 Use  is_mutable=False  to add an immutable database. \n                 .add_database()  returns the Database instance, with its name set as the  database.name  attribute. Any time you are working with a newly added database you should use the return value of  .add_database() , for example: \n                 db = datasette.add_database(\n    Database(datasette, memory_name=\"statistics\")\n)\nawait db.execute_write(\n    \"CREATE TABLE foo(id integer primary key)\"\n)", "breadcrumbs": "[\"Internals for plugins\", \"Datasette class\"]", "references": "[]"}], "truncated": false}