filmov
tv
Run SQL in Python Fast with SQLite (Copy & Paste Trick Data Scientists Love)

Показать описание
How to Link SQL to Python?
In this video, I’ll show you how to use SQLite—a built-in, serverless SQL engine in Python—to run powerful SQL queries directly inside your Jupyter Notebook and return clean Pandas DataFrames. Whether you’re used to SQL Server, MySQL, or BigQuery, this SQLite tutorial will give you the freedom to run full SQL with just a few lines of Python. Perfect for data scientist doing SQL for data analysis.
Specifically, you will learn:
00:58 Why you don't need SQL server as Data Scientist
03:23 How to Link SQL to Python using the right Script
05:41 A real-world example: customer loan product analysis
Linkedin:
All the Python + SQL code used in this video is simple, reusable, and included below 👇
import pandas as pd
import sqlalchemy as sa
from sqlalchemy import text
def query_from_db(string1, engine):
"""
Execute SQL Statement and return the queried data as a pandas.DataFrame object
:param sql_long_string: SQL statement
:param engine: SQL Alchemy engine
"""
# Wrap the raw SQL string in a `text` object
statement1 = text(string1)
# Execute the query using the engine
return df1
#sqlite #sqltips #pandasdataframe #datasciencetools
In this video, I’ll show you how to use SQLite—a built-in, serverless SQL engine in Python—to run powerful SQL queries directly inside your Jupyter Notebook and return clean Pandas DataFrames. Whether you’re used to SQL Server, MySQL, or BigQuery, this SQLite tutorial will give you the freedom to run full SQL with just a few lines of Python. Perfect for data scientist doing SQL for data analysis.
Specifically, you will learn:
00:58 Why you don't need SQL server as Data Scientist
03:23 How to Link SQL to Python using the right Script
05:41 A real-world example: customer loan product analysis
Linkedin:
All the Python + SQL code used in this video is simple, reusable, and included below 👇
import pandas as pd
import sqlalchemy as sa
from sqlalchemy import text
def query_from_db(string1, engine):
"""
Execute SQL Statement and return the queried data as a pandas.DataFrame object
:param sql_long_string: SQL statement
:param engine: SQL Alchemy engine
"""
# Wrap the raw SQL string in a `text` object
statement1 = text(string1)
# Execute the query using the engine
return df1
#sqlite #sqltips #pandasdataframe #datasciencetools