29 lines
947 B
Python
29 lines
947 B
Python
from sqlalchemy import create_engine
|
|
from sqlalchemy.orm import sessionmaker
|
|
from quetz.db_models import Channel, Base
|
|
from quetz.config import Config
|
|
|
|
channel_name = "conda-forge"
|
|
|
|
# Load your quetz config (picks up database.url from config.toml)
|
|
config = Config("/data/config.toml")
|
|
|
|
engine = create_engine(config.sqlalchemy_database_url)
|
|
SessionLocal = sessionmaker(bind=engine)
|
|
|
|
with SessionLocal() as db:
|
|
existing = db.query(Channel).filter(Channel.name == channel_name).first()
|
|
if not existing:
|
|
channel = Channel(
|
|
name=channel_name,
|
|
description="Proxy of conda-forge",
|
|
private=False,
|
|
mirror_channel_url="https://conda.anaconda.org/conda-forge",
|
|
mirror_mode="proxy",
|
|
)
|
|
db.add(channel)
|
|
db.commit()
|
|
print(f"Channel created: {channel.name}")
|
|
else:
|
|
print(f"Skipping channel creation - channel already exists: {channel_name}")
|