Skip to content
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

Created Concept Entry for Python SQL Connectors #5683

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Rendon-04
Copy link

@Rendon-04 Rendon-04 commented Nov 26, 2024

Description

Issue Solved

Closes #5633

Type of Change

This pull request adds documentation for the mysql-connector-python library, including examples for setting up connections and executing SQL queries.

  • Adding a new entry

Checklist

  • All writings are my own.
  • My entry follows the Codecademy Docs style guide.
  • My changes generate no new warnings.
  • I have performed a self-review of my own writing and code.
  • I have checked my entry and corrected any misspellings.
  • I have made corresponding changes to the documentation if needed.
  • I have confirmed my changes are not being pushed from my forked main branch.
  • I have confirmed that I'm pushing from a new branch named after the changes I'm making.
  • I have linked any issues that are relevant to this PR in the Issues Solved section.

@CLAassistant
Copy link

CLAassistant commented Nov 26, 2024

CLA assistant check
All committers have signed the CLA.

@SaviDahegaonkar SaviDahegaonkar self-assigned this Nov 26, 2024
@SaviDahegaonkar SaviDahegaonkar added new entry New entry or entries mysql MySQL status: under review Issue or PR is currently being reviewed labels Nov 26, 2024
Comment on lines +19 to +20
## Setting Up a SQL Connector
To use a SQL connector, you first need to set up your development environment. This includes installing the appropriate connector library for you database and making sure that youre database server is accessible.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
## Setting Up a SQL Connector
To use a SQL connector, you first need to set up your development environment. This includes installing the appropriate connector library for you database and making sure that youre database server is accessible.
## Setting Up a SQL Connector
To use a SQL connector, you first need to set up your development environment. This includes installing the appropriate connector library for your database and ensuring that your database server is accessible.

Made the sentence more readable by correcting the grammatical mistakes.

Comment on lines +21 to +31
1. Install the Connector:
- For MySQL: Use ```pip install mysql-connector-python```.
- For PostgreSQL: Use ```pip install psycopg2```
- For SQLite: No installation is needed; it is built into Python's standard library.

2. Set Up the Database
- Make sure the database server is running and accessible.
- Create or access an exisiting database.

3. Import the Connector Library
Use the appropriate Python module to work with the database, such as ```mysql.connector``` for MySQL or ```sqlite3``` for SQLite.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
1. Install the Connector:
- For MySQL: Use ```pip install mysql-connector-python```.
- For PostgreSQL: Use ```pip install psycopg2```
- For SQLite: No installation is needed; it is built into Python's standard library.
2. Set Up the Database
- Make sure the database server is running and accessible.
- Create or access an exisiting database.
3. Import the Connector Library
Use the appropriate Python module to work with the database, such as ```mysql.connector``` for MySQL or ```sqlite3``` for SQLite.
1. Install the Connector:
- For MySQL: Use ```pip install mysql-connector-python```.
- For PostgreSQL: Use ```pip install psycopg2```.
- For SQLite: No installation is needed; it is built into Python's standard library.
2. Set Up the Database
- Ensure the database server is running and accessible.
- Create or access an existing database.
3. Import the Connector Library
Use the appropriate Python module to work with the database, such as ```mysql.connector``` for MySQL or ```sqlite3``` for SQLite.

Comment on lines +41 to +44
**General Workflow:**
- Import the connector library.
- Use the `connect()` method to establish a connection.
- Handle connection errors with try-except blocks.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
**General Workflow:**
- Import the connector library.
- Use the `connect()` method to establish a connection.
- Handle connection errors with try-except blocks.

Removed the redundant part

Comment on lines +63 to +66
**Query Execution:**

- Use `cursor.execute()` to run queries.
- Use `cursor.fetchall()` to fetch data for SELECT queries.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
**Query Execution:**
- Use `cursor.execute()` to run queries.
- Use `cursor.fetchall()` to fetch data for SELECT queries.
**Query Execution:**
- Use `cursor.execute()` to execute SQL queries.
- Use `cursor.fetchall()` to fetch all rows from a `SELECT` query.

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

Successfully merging this pull request may close these issues.

[Concept Entry] Python SQL Connectors
4 participants