Skip to content

Commit

Permalink
style: reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
phanhongan committed Oct 26, 2024
1 parent 39b218b commit 7227879
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions examples/use-rdb-resource/make_example_table_data.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
from sqlalchemy import Column, Integer, String, Date, inspect, create_engine
from sqlalchemy.orm import sessionmaker, declarative_base
from faker import Faker
import os
import random

from dotenv import load_dotenv
import os
from faker import Faker
from sqlalchemy import Column, Integer, String, Date, inspect, create_engine
from sqlalchemy.orm import sessionmaker, declarative_base

from myvanna import train_vanna_for_sales_data

load_dotenv()

Base = declarative_base()


class SalesData(Base):
__tablename__ = 'sales_data'
sale_id = Column(Integer, primary_key=True, autoincrement=True)
Expand All @@ -18,6 +21,7 @@ class SalesData(Base):
sale_date = Column(Date)
region = Column(String(255))


class MySQLDatabase:
def __init__(self):
self.engine = self.create_engine()
Expand All @@ -43,6 +47,7 @@ def drop_table(self, table_class):
if inspector.has_table(table_class.__tablename__):
table_class.__table__.drop(self.engine)


fake = Faker()
seed_value = 42
random.seed(seed_value)
Expand All @@ -58,6 +63,7 @@ def drop_table(self, table_class):

regions = ["North America", "Europe", "Asia", "South America", "Africa"]


def generate_sales_data(session, num_records):
sales_data_list = []
for _ in range(num_records):
Expand All @@ -74,6 +80,7 @@ def generate_sales_data(session, num_records):
session.bulk_save_objects(sales_data_list)
session.commit()


if __name__ == "__main__":
db = MySQLDatabase()

Expand Down

0 comments on commit 7227879

Please sign in to comment.