Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@NarayanaSabari
Copy link

@NarayanaSabari NarayanaSabari commented Nov 6, 2025

Add PostgreSQL Integration Example

Adds a PostgreSQL integration example following the guidance from Discussion #125.

Changes

Adds examples/integrations/postgresql/ with:

README.md

  • Docker-based setup instructions
  • Connection configuration
  • Troubleshooting guide

postgresql-example.deepnote (24 cells)

  • Connection setup and testing
  • CRUD operations on e-commerce database
  • Complex queries (JOINs, aggregations, views)
  • Geographic and time-series analysis

sample_data.sql

  • E-commerce schema (customers, products, orders, order_items)
  • Foreign keys, constraints, indexes
  • Two analytical views (order_summary, product_sales)
  • Sample data: 10 customers, 12 products, 14 orders

Testing

Tested locally with:

  • PostgreSQL 15 (Docker)
  • Python 3.11, psycopg2-binary 2.9.9, pandas 2.1.3
  • All cells execute successfully

Checklist

  • Follows existing examples/ structure
  • Comprehensive documentation
  • No hardcoded credentials
  • Docker-first approach
  • Error handling included

Thanks 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

    • Added comprehensive PostgreSQL integration guide covering setup, Docker deployment, prerequisites, and troubleshooting steps.
  • New Features

    • Introduced PostgreSQL integration example notebook demonstrating CRUD operations, data exploration, and analytical queries.
    • Added complete sample e-commerce database schema with tables, views, and indexes for testing.

@NarayanaSabari NarayanaSabari requested a review from a team as a code owner November 6, 2025 10:55
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 6, 2025

📝 Walkthrough

Walkthrough

The 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)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add PostgreSQL Integration Example' directly and accurately describes the main change: introducing a new PostgreSQL integration example with documentation, a Deepnote notebook, and sample data.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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.

📥 Commits

Reviewing files that changed from the base of the PR and between b7c4907 and cf47ea8.

📒 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_checkpoints is the standard directory created by Jupyter for checkpoint data. This entry correctly excludes it from version control.

Comment on lines +500 to +538
- 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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.

Suggested change
- 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.

Comment on lines +82 to +89
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
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant