-
Notifications
You must be signed in to change notification settings - Fork 152
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
Create script to populate with fake data db #151
Conversation
Create script to populate with fake data in the db
@djeck_vorobey please review. thank you |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix pylint issues:
pylint $(git ls-files '*.py') --disable=all --enable=C0114,C0115,C0116,C0301
run this command to see them
web_app/db/README.md
Outdated
1. **Install Dependencies**: Ensure you have the required packages installed. You can do this by running: | ||
|
||
```bash | ||
pip install sqlalchemy psycopg2 faker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't use on the project pip
, please add these dependencies add to pyproject.toml
most of them already there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay sir
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use pip
please change it
we use poetry
web_app/db/seed_data.py
Outdated
from sqlalchemy import create_engine | ||
from sqlalchemy.orm import sessionmaker | ||
from faker import Faker | ||
# from web_app.db.models import User, Position, AirDrop, TelegramUser |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove unused imports
web_app/db/seed_data.py
Outdated
# Create a new database session | ||
engine = create_engine(DATABASE_URL) | ||
Session = sessionmaker(bind=engine) | ||
session = Session() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REmove this code:
# Database connection settings
DB_USER = os.getenv("DB_USER")
DB_PASSWORD = os.getenv("DB_PASSWORD")
DB_NAME = os.getenv("DB_NAME")
DB_HOST = os.getenv("DB_HOST")
DB_PORT = os.getenv("DB_PORT")
DATABASE_URL = "postgresql+psycopg2://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}"
# Create a new database session
engine = create_engine(DATABASE_URL)
Session = sessionmaker(bind=engine)
session = Session()
import it from here
web_app/db/seed_data.py
Outdated
# Initialize Faker | ||
fake = Faker() | ||
|
||
def create_users(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add docstring and annotation types
![]() |
i have successfully populated the database with the dummy data
@djeck1432 please review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you run this script? If yes, attach screenshot of creating fake data in db
web_app/db/README.md
Outdated
1. **Install Dependencies**: Ensure you have the required packages installed. You can do this by running: | ||
|
||
```bash | ||
pip install sqlalchemy psycopg2 faker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use pip
please change it
we use poetry
web_app/db/seed_data.py
Outdated
""" | ||
positions = [] | ||
for user in users: | ||
if user.id is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how can it be possible that user.id is None if you created it before?
web_app/db/seed_data.py
Outdated
create_airdrops(session, users) | ||
create_telegram_users(session, users) | ||
|
||
print("Database populated with fake data.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why in some place you use loggin
and here print
?
please, it's not consistently
@djeck1432 please review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
Created script to populate db with dummy data