I am not a heavy coding developer, but I have this issue I have a data set of the ID - Time series - Velocity on SQL
I want to divide the data set based on the unique values of ID into 1700 CSV files (which is the unique numbers of ID)
When I ran the following code, the windows stopped working. I need some help in doing the same thing either through Dynamic SQL or through something else.
P.S. The database is 300 Million rows
import pyodbc
import numpy as np
import pandas as pd
db = pyodbc.connect("Driver={SQL Server Native Client 11.0};" "Server=ServerName;""Database;""Trusted_Connection=yes;")
df = pd.read_sql_query("SELECT* from DataBase", db)
ID = df['ID'].unique()
dfs={}
SR=()
for i, S in enumerate(ID):
dfs[i]=df[df['ID']==S]
filename=S+'.CSV'
df.to_csv(filename)