Skip to content

Commit

Permalink
Update views/aggregate-block-metadata.json
Browse files Browse the repository at this point in the history
Co-authored-by: Alexander Streed <[email protected]>
  • Loading branch information
zzstoatzz and desertaxle authored Oct 10, 2023
1 parent b0134da commit 4f073ce
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion views/aggregate-block-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -8432,7 +8432,7 @@
"sqlalchemy-connector": {
"name": "SQLAlchemy Connector",
"slug": "sqlalchemy-connector",
"logo_url": "https://images.ctfassets.net/gm98wzqotmnx/37TOcxeP9kfXffpKVRAHiJ/0f359112e79d0bd3dfe38c73c4fc6363/sqlalchemy.png?h=250",
"logo_url": "https://cdn.sanity.io/images/3ugk85nk/production/3c7dff04f70aaf4528e184a3b028f9e40b98d68c-250x250.png",
"documentation_url": "https://prefecthq.github.io/prefect-sqlalchemy/database/#prefect_sqlalchemy.database.SqlAlchemyConnector",
"description": "Block used to manage authentication with a database.\n\nUpon instantiating, an engine is created and maintained for the life of\nthe object until the close method is called.\n\nIt is recommended to use this block as a context manager, which will automatically\nclose the engine and its connections when the context is exited.\n\nIt is also recommended that this block is loaded and consumed within a single task\nor flow because if the block is passed across separate tasks and flows,\nthe state of the block's connection and cursor could be lost. This block is part of the prefect-sqlalchemy collection. Install prefect-sqlalchemy with `pip install prefect-sqlalchemy` to use this block.",
"code_example": "Load stored database credentials and use in context manager:\n```python\nfrom prefect_sqlalchemy import SqlAlchemyConnector\n\ndatabase_block = SqlAlchemyConnector.load(\"BLOCK_NAME\")\nwith database_block:\n ...\n```\n\nCreate table named customers and insert values; then fetch the first 10 rows.\n```python\nfrom prefect_sqlalchemy import (\n SqlAlchemyConnector, SyncDriver, ConnectionComponents\n)\n\nwith SqlAlchemyConnector(\n connection_info=ConnectionComponents(\n driver=SyncDriver.SQLITE_PYSQLITE,\n database=\"prefect.db\"\n )\n) as database:\n database.execute(\n \"CREATE TABLE IF NOT EXISTS customers (name varchar, address varchar);\",\n )\n for i in range(1, 42):\n database.execute(\n \"INSERT INTO customers (name, address) VALUES (:name, :address);\",\n parameters={\"name\": \"Marvin\", \"address\": f\"Highway {i}\"},\n )\n results = database.fetch_many(\n \"SELECT * FROM customers WHERE name = :name;\",\n parameters={\"name\": \"Marvin\"},\n size=10\n )\nprint(results)\n```",
Expand Down

0 comments on commit 4f073ce

Please sign in to comment.