I am trying to create a database using sqlalchemy and connecting it to mysql. And when creating an engine, while entering a password that contains "@", it takes the local host starting from the "@". I've tried changing the password to something that doesnt contain "@" and it created it. How can I create a database without having limitations on the password?
Error log: (2003, "Can't connect to MySQL server on '1234@localhost' ([Errno -2] Name or service not known)")
from enum import unique
from lib2to3.pytree import Base
import sqlalchemy
from enum import Enum
from sqlalchemy import create_engine, Column, Integer, String, Table
from sqlalchemy.orm import sessionmaker, relationship
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import MetaData
from sqlalchemy_utils import database_exists, create_database
Base = declarative_base()
)
class User(Base):
__tablename__ = 'user'
id = Column("ID", Integer, primary_key=True)
name = Column("username", String(255), unique=True)
****engine = create_engine(
"mysql+pymysql://admin:Admin@1234@localhost:3306/ABC", echo=True)****
if not database_exists(engine.url):
create_database(engine.url)
# conn = engine.connect()
Base.metadata.create_all(bind=engine)
Session = sessionmaker(bind=engine)
session = Session()
session.close()