Skip to content

Latest commit

 

History

History
31 lines (23 loc) · 413 Bytes

MySQL.md

File metadata and controls

31 lines (23 loc) · 413 Bytes

MySQL

import mysql.connector

conn = mysql.connector.connect(
    host='...',
    password='...',
    port=3306,
    user='root',
    database='...',
)

sql = """
SELECT
  id,
  , email
FROM auth_user
"""


cursor = conn.cursor()
cursor.execute(sql)

rows = cursor.fetchall()

import pandas as pd

df = pd.DataFrame(rows, columns=['id', 'email'])
df.to_csv('default_repo/users.csv', index=False)