Spaces:
Sleeping
Sleeping
File size: 2,927 Bytes
1b4300e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | import asyncio
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
from sqlalchemy.orm import sessionmaker
from database.models import Base, Category, Service
from decimal import Decimal
DATABASE_URL = "postgresql+asyncpg://postgres:postgres@localhost:5432/growthpanel"
async def seed_data():
engine = create_async_engine(DATABASE_URL, echo=True)
async_session = sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
async with async_session() as session:
async with session.begin():
# Create Categories
cat_list = [
Category(name="Instagram - Followers", slug="instagram-followers", icon="📸", sort_order=1),
Category(name="Instagram - Likes", slug="instagram-likes", icon="❤️", sort_order=2),
Category(name="TikTok - Views", slug="tiktok-views", icon="📱", sort_order=3),
Category(name="YouTube - Subscribers", slug="youtube-subscribers", icon="📺", sort_order=4),
]
session.add_all(cat_list)
await session.flush()
# Create Services
services_list = [
Service(
category_id=cat_list[0].id,
name="Instagram Followers [Real & Active] - 30 Days Refill",
price_per_1000=Decimal("1.50"),
min_quantity=100,
max_quantity=100000,
average_time="1-6 Hours",
status="active"
),
Service(
category_id=cat_list[0].id,
name="Instagram Followers [Standard Quality] - No Refill",
price_per_1000=Decimal("0.85"),
min_quantity=100,
max_quantity=500000,
average_time="Instant",
status="active"
),
Service(
category_id=cat_list[1].id,
name="Instagram Real Likes - Fast Delivery",
price_per_1000=Decimal("0.45"),
min_quantity=50,
max_quantity=50000,
average_time="0-15 Min",
status="active"
),
Service(
category_id=cat_list[2].id,
name="TikTok Views [Max 10M] - High Speed",
price_per_1000=Decimal("0.05"),
min_quantity=1000,
max_quantity=10000000,
average_time="Instant",
status="active"
)
]
session.add_all(services_list)
await session.commit()
print("Database seeded successfully!")
if __name__ == "__main__":
asyncio.run(seed_data())
|