私信  •  关注

Max

Max 最近回复了
2 年前
回复了 Max 创建的主题 » 如何为python discord机器人导入/使用ctx?

如果要使用ctx参数,应该使用discord的命令扩展。皮耶。在 on_message 事件您可以使用 message 参数“作为ctx参数”。

@client.event
async def on_message(message):
    if message.author != client.user:
        if message.content.startswith(""):
            print(message.content)
            guild = message.guild
            await guild.create_text_channel('cool-channel')
4 年前
回复了 Max 创建的主题 » SQL Server Docker Compose SQLCMD不执行

这是因为SQL Server实例未启动,您必须等待它。

Docker Hub official page of SQL Server run a sql script on Docker container .

下面我为您重新修改了GitHub代码

# Typically SQL Server takes about 5-10 seconds to start up 
# Wait for the SQL Server to come up (90 sec) You can reduce to 20sec and see
sleep 90s

#run the setup script to create the DB and the schema in the DB
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P password -d master -i prod.sql

入口点.sh

#start SQL Server, start the script to create the DB and import the data
/opt/mssql/bin/sqlservr & initialize.sh 

停靠文件

FROM mcr.microsoft.com/mssql/server:2019-GA-ubuntu-16.04
COPY ./prod.sql /

# Grant permissions for the import-data script to be executable
RUN chmod +x ./initialize.sh

CMD /bin/bash ./entrypoint.sh

我个人提出的另一个解决方案是运行SQL Server服务并等待该服务出现。

创建.sh

/opt/mssql-tools/bin/sqlcmd -U sa -P $1 -Q 'CREATE DATABASE [MyNewDatabase]'
/opt/mssql-tools/bin/sqlcmd -U sa -P $1 -d 'MyNewDatabase' -i /src/script.sql

脚本.sql

CREATE TABLE MyTable (..)


FROM mcr.microsoft.com/mssql/server:2017-latest-ubuntu
EXPOSE 1433

WORKDIR /
COPY ./create.sh /src/
COPY ./script.sql /src/

ENV ACCEPT_EULA Y
ENV SA_PASSWORD P@ssw0rd

RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc

RUN ( /opt/mssql/bin/sqlservr --accept-eula & ) | grep -q "Service Broker manager has started" \
    && /src/create.sh P@ssw0rd \
    && pkill sqlservr

4 年前
回复了 Max 创建的主题 » Python string.strip()显示了奇怪的行为

我知道你说过你想用string.strip,但如果你改变主意,你可以切

my_string = 'H:\\Jupyter\\SAF_Prewfdsds\\Testings_05601252\\050_7_150_PYPL.csv'
sliced_string = my_string[-8:]
5 年前
回复了 Max 创建的主题 » 未加载django表单初始值

我的错误是初始值应该是id,而应该是id和value的元组。

8 年前
回复了 Max 创建的主题 » python正在为datetime创建if语句[重复]
if d.total_seconds() > 60:
  print("elapsed time is greater than 1 minute")

但它需要Python2.7+