Skip to content
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

Merged
merged 6 commits into from
Oct 31, 2024

Conversation

caxtonacollins
Copy link
Contributor

Created script to populate db with dummy data

Create script to populate with fake data in the db
@caxtonacollins
Copy link
Contributor Author

@djeck_vorobey please review. thank you

@djeck1432 djeck1432 self-requested a review October 30, 2024 18:50
@djeck1432 djeck1432 linked an issue Oct 30, 2024 that may be closed by this pull request
Copy link
Owner

@djeck1432 djeck1432 left a 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

1. **Install Dependencies**: Ensure you have the required packages installed. You can do this by running:

```bash
pip install sqlalchemy psycopg2 faker
Copy link
Owner

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay sir

Copy link
Owner

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

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from faker import Faker
# from web_app.db.models import User, Position, AirDrop, TelegramUser
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove unused imports

# Create a new database session
engine = create_engine(DATABASE_URL)
Session = sessionmaker(bind=engine)
session = Session()
Copy link
Owner

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

# Initialize Faker
fake = Faker()

def create_users():
Copy link
Owner

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

@djeck1432
Copy link
Owner

Screenshot 2024-10-30 at 20 49 4 @caxtonacollins fix pylint, please

i have successfully populated the database with the dummy data
@caxtonacollins
Copy link
Contributor Author

@djeck1432 please review

Copy link
Owner

@djeck1432 djeck1432 left a 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

1. **Install Dependencies**: Ensure you have the required packages installed. You can do this by running:

```bash
pip install sqlalchemy psycopg2 faker
Copy link
Owner

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

"""
positions = []
for user in users:
if user.id is None:
Copy link
Owner

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?

create_airdrops(session, users)
create_telegram_users(session, users)

print("Database populated with fake data.")
Copy link
Owner

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

@caxtonacollins
Copy link
Contributor Author

Screenshot 2024-10-31 134608

@djeck1432 please review

Copy link
Owner

@djeck1432 djeck1432 left a 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

@djeck1432 djeck1432 merged commit 138b175 into djeck1432:main Oct 31, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create script to populate with fake data db.
2 participants