-
Notifications
You must be signed in to change notification settings - Fork 69
Add PostgreSQL Integration Example #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThe PR adds a PostgreSQL integration example to the repository. It includes a README documenting setup and workflow, a Deepnote notebook demonstrating CRUD operations and data exploration using psycopg2 and pandas, and a SQL script defining an e-commerce schema with four tables, two views, and five indexes. The .gitignore is updated to exclude Jupyter checkpoint files. Pre-merge checks❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (4)
.gitignore(1 hunks)examples/integrations/postgresql/README.md(1 hunks)examples/integrations/postgresql/postgresql-example.deepnote(1 hunks)examples/integrations/postgresql/sample_data.sql(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{md,yml,yaml}
📄 CodeRabbit inference engine (CLAUDE.md)
Use Prettier formatting for Markdown and YAML files
Files:
examples/integrations/postgresql/README.md
🪛 markdownlint-cli2 (0.18.1)
examples/integrations/postgresql/README.md
45-45: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
83-83: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
🔇 Additional comments (1)
.gitignore (1)
12-12: Standard and appropriate addition.
.ipynb_checkpointsis the standard directory created by Jupyter for checkpoint data. This entry correctly excludes it from version control.
| - blockGroup: 232f83bf-357e-4086-b293-b82eabc39e30 | ||
| content: |- | ||
| ## Cleanup (Optional) | ||
|
|
||
| Run this cell only if you want to remove ALL sample data. | ||
| id: 1c9a9af8ed88efb710ce97b5ad5cde3a | ||
| metadata: {} | ||
| sortingKey: a15 | ||
| type: markdown | ||
| - blockGroup: bd81a9f0-1ad8-4c94-9c22-0ef849d8b5f7 | ||
| content: |- | ||
| # WARNING: This will delete all sample data! | ||
| # Uncomment the code below to run cleanup | ||
|
|
||
| # conn = psycopg2.connect(**conn_params) | ||
| # cursor = conn.cursor() | ||
|
|
||
| # try: | ||
| # cursor.execute('DROP TABLE IF EXISTS order_items CASCADE;') | ||
| # cursor.execute('DROP TABLE IF EXISTS orders CASCADE;') | ||
| # cursor.execute('DROP TABLE IF EXISTS products CASCADE;') | ||
| # cursor.execute('DROP TABLE IF EXISTS customers CASCADE;') | ||
| # cursor.execute('DROP VIEW IF EXISTS order_summary CASCADE;') | ||
| # cursor.execute('DROP VIEW IF EXISTS product_sales CASCADE;') | ||
| # conn.commit() | ||
| # print("✓ All sample tables and views removed") | ||
| # except Exception as e: | ||
| # conn.rollback() | ||
| # print(f"✗ Error during cleanup: {e}") | ||
| # finally: | ||
| # cursor.close() | ||
| # conn.close() | ||
|
|
||
| print("⚠️ Cleanup code is commented out for safety.") | ||
| print("Uncomment the code above to delete all sample data.") | ||
| id: 76559c7769c4efee07fd1d6c14dd5584 | ||
| metadata: {} | ||
| sortingKey: a16 | ||
| type: code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix duplicate sortingKey values.
The cleanup blocks use sortingKeys a15 and a16, which are already used by the geographic analysis blocks (lines 344, 371). This causes undefined ordering behavior.
Apply this diff:
metadata: {}
- sortingKey: a15
+ sortingKey: a23
type: markdown
- blockGroup: bd81a9f0-1ad8-4c94-9c22-0ef849d8b5f7 metadata: {}
- sortingKey: a16
+ sortingKey: a24
type: code
executionMode: block📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| - blockGroup: 232f83bf-357e-4086-b293-b82eabc39e30 | |
| content: |- | |
| ## Cleanup (Optional) | |
| Run this cell only if you want to remove ALL sample data. | |
| id: 1c9a9af8ed88efb710ce97b5ad5cde3a | |
| metadata: {} | |
| sortingKey: a15 | |
| type: markdown | |
| - blockGroup: bd81a9f0-1ad8-4c94-9c22-0ef849d8b5f7 | |
| content: |- | |
| # WARNING: This will delete all sample data! | |
| # Uncomment the code below to run cleanup | |
| # conn = psycopg2.connect(**conn_params) | |
| # cursor = conn.cursor() | |
| # try: | |
| # cursor.execute('DROP TABLE IF EXISTS order_items CASCADE;') | |
| # cursor.execute('DROP TABLE IF EXISTS orders CASCADE;') | |
| # cursor.execute('DROP TABLE IF EXISTS products CASCADE;') | |
| # cursor.execute('DROP TABLE IF EXISTS customers CASCADE;') | |
| # cursor.execute('DROP VIEW IF EXISTS order_summary CASCADE;') | |
| # cursor.execute('DROP VIEW IF EXISTS product_sales CASCADE;') | |
| # conn.commit() | |
| # print("✓ All sample tables and views removed") | |
| # except Exception as e: | |
| # conn.rollback() | |
| # print(f"✗ Error during cleanup: {e}") | |
| # finally: | |
| # cursor.close() | |
| # conn.close() | |
| print("⚠️ Cleanup code is commented out for safety.") | |
| print("Uncomment the code above to delete all sample data.") | |
| id: 76559c7769c4efee07fd1d6c14dd5584 | |
| metadata: {} | |
| sortingKey: a16 | |
| type: code | |
| - blockGroup: 232f83bf-357e-4086-b293-b82eabc39e30 | |
| content: |- | |
| ## Cleanup (Optional) | |
| Run this cell only if you want to remove ALL sample data. | |
| id: 1c9a9af8ed88efb710ce97b5ad5cde3a | |
| metadata: {} | |
| sortingKey: a23 | |
| type: markdown | |
| - blockGroup: bd81a9f0-1ad8-4c94-9c22-0ef849d8b5f7 | |
| content: |- | |
| # WARNING: This will delete all sample data! | |
| # Uncomment the code below to run cleanup | |
| # conn = psycopg2.connect(**conn_params) | |
| # cursor = conn.cursor() | |
| # try: | |
| # cursor.execute('DROP TABLE IF EXISTS order_items CASCADE;') | |
| # cursor.execute('DROP TABLE IF EXISTS orders CASCADE;') | |
| # cursor.execute('DROP TABLE IF EXISTS products CASCADE;') | |
| # cursor.execute('DROP TABLE IF EXISTS customers CASCADE;') | |
| # cursor.execute('DROP VIEW IF EXISTS order_summary CASCADE;') | |
| # cursor.execute('DROP VIEW IF EXISTS product_sales CASCADE;') | |
| # conn.commit() | |
| # print("✓ All sample tables and views removed") | |
| # except Exception as e: | |
| # conn.rollback() | |
| # print(f"✗ Error during cleanup: {e}") | |
| # finally: | |
| # cursor.close() | |
| # conn.close() | |
| print("⚠️ Cleanup code is commented out for safety.") | |
| print("Uncomment the code above to delete all sample data.") | |
| id: 76559c7769c4efee07fd1d6c14dd5584 | |
| metadata: {} | |
| sortingKey: a24 | |
| type: code |
🤖 Prompt for AI Agents
In examples/integrations/postgresql/postgresql-example.deepnote around lines 500
to 538 the two cleanup blocks reuse sortingKey values a15 and a16 which collide
with geographic analysis blocks at lines ~344 and ~371; change these two
sortingKey values to unused, unique keys (e.g., a17 and a18 or another sequence
not present in the file) by updating the sortingKey field for both the markdown
block (id 1c9a9af8ed88efb710ce97b5ad5cde3a) and the code block (id
76559c7769c4efee07fd1d6c14dd5584), and verify no other blocks use the new keys
to restore deterministic ordering.
| Load it into your database: | ||
| ```bash | ||
| # Docker | ||
| docker exec -i deepnote-postgres psql -U postgres < sample_data.sql | ||
|
|
||
| # Local PostgreSQL | ||
| psql -U postgres < sample_data.sql | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add blank lines around code block.
Per coding guidelines, fenced code blocks require surrounding blank lines.
Apply this diff:
Load it into your database:
+
```bash
# Docker
docker exec -i deepnote-postgres psql -U postgres < sample_data.sql
# Local PostgreSQL
psql -U postgres < sample_data.sql
<details>
<summary>🧰 Tools</summary>
<details>
<summary>🪛 markdownlint-cli2 (0.18.1)</summary>
83-83: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
</details>
</details>
<details>
<summary>🤖 Prompt for AI Agents</summary>
examples/integrations/postgresql/README.md lines 82-89: the fenced code block
needs a blank line before the opening ```bash and a blank line after the closing
above the opening fence and one empty line below the closing fence so the block
is surrounded by blank lines.
Add PostgreSQL Integration Example
Adds a PostgreSQL integration example following the guidance from Discussion #125.
Changes
Adds
examples/integrations/postgresql/with:README.md
postgresql-example.deepnote (24 cells)
sample_data.sql
Testing
Tested locally with:
Checklist
examples/structureThanks for reviewing! I'm excited to contribute to the Deepnote community and happy to make any adjustments based on your feedback. 🚀
cc: @mikayelh
Summary by CodeRabbit
Documentation
New Features