使用SQLAlchemy,引擎创建如下:
from sqlalchemy import create_engine
engine = create_engine("postgresql://localhost/mydb")
Run Code Online (Sandbox Code Playgroud)
engine
如果数据库不存在,则访问失败.如果指定的数据库不存在,是否可以告诉SQLAlchemy创建新数据库?
我想/etc/nginx/sites-enabled
用符号链接代替我的仓库.我正在尝试使用file
模块执行此操作,但这不起作用,因为文件模块不会使用force选项删除目录.
- name: setup nginx sites-available symlink
file: path=/etc/nginx/sites-available src=/repo/etc/nginx/sites-available state=link force=yes
notify: restart nginx
Run Code Online (Sandbox Code Playgroud)
我可以回到使用shell.
- name: setup nginx sites-available symlink
shell: test -d /etc/nginx/sites-available && rm -r /etc/nginx/sites-available && ln -sT /repo/etc/nginx/sites-available /etc/nginx/sites-available
notify: restart nginx
Run Code Online (Sandbox Code Playgroud)
有没有更好的方法来实现这一点,而不是回到shell?
我正在从mysql迁移到postgres.作为其中的一部分,我在使用sed处理mysql转储之前将其加载到postgres中.
我的MySQL转储有一些\0
字符,而postgres不喜欢它们.所以我用空格替换它们.
sed 's/\\0/ /g' $dumpfile
Run Code Online (Sandbox Code Playgroud)
当线路出现时注意到一个问题320.48k\\02. Easy Listening
.
$ echo '320.48k\\02. Easy Listening' | sed 's/\\0/ /g'
320.48k\ 2. Easy Listening
Run Code Online (Sandbox Code Playgroud)
那不是我想要的.\\
后跟的0
字符不是空字符.我想保持原样.
有没有sed专家帮忙?