小编Mic*_*icz的帖子

Alembic 自动生成迁移,无需检查约束

我是 alembic 和 sqlalchemy 世界的新手
可以说我有模型:

class Model(Base):
    __tablename__ = 'models'
    id = Column(Integer, primary_key=True)
    value = Column(Integer, CheckContraint('value >= 0'))
Run Code Online (Sandbox Code Playgroud)

如果我做 alembic --config=development.ini revision --autogenerate -m "init" 我得到例如

def upgrade():
    op.create_table('models',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('value', sa.Integer())
Run Code Online (Sandbox Code Playgroud)

在这里我错过了 create_check_constraint 我怎样才能自动执行它还是应该手动添加它?我希望它能与 postgresql 一起使用

python migration postgresql sqlalchemy alembic

5
推荐指数
1
解决办法
1285
查看次数

ruby sass-rails gem和heroku推送错误

在我的电脑上一切正常,但我无法推送到Heroku.
我正在做一个名为"Ruby on Rails Tutorial(3rd Ed.)"的流行RoR教程,他们希望我在Gemfile中拥有一行

gem 'sass-rails',   '5.0.1'
Run Code Online (Sandbox Code Playgroud)

没有那条线我推动时没有问题,但如果添加这条线我得到:

->git push heroku master 
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 321 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.2.1
remote: -----> Installing dependencies using 1.7.12
remote:        Ruby …
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails sass heroku gemfile

4
推荐指数
1
解决办法
717
查看次数

qemu virtio-9p-pci不是有效的设备型号名称

我想用命令运行qemu

qemu-system-x86_64 \
    -drive file=zso_cow.img,if=virtio \
    -enable-kvm \
    -smp 2 \
    -net nic,model=virtio -net user \
    -m 1G -balloon virtio \
    -fsdev local,id=hshare,path=hshare/,security_model=none -device virtio-9p-pci,fsdev=hshare,mount_tag=hshare \
    -chardev stdio,id=cons,signal=off -device virtio-serial-pci -device virtconsole,chardev=cons \
    -device harddoom
Run Code Online (Sandbox Code Playgroud)

但我收到一个错误:qemu-system-x86_64:-device virtio-9p-pci,fsdev = hshare,mount_tag = hshare:'virtio-9p-pci'不是有效的设备型号名称

qemu是使用配置选项从分支harddoom上的源代码编译的:

--target-list=i386-softmmu,x86_64-softmmu --python=$(which python2)
--audio-drv-list=alsa,pa
Run Code Online (Sandbox Code Playgroud)

我没有从ubuntu仓库安装qemu的问题,但是我需要使用从源代码编译的版本。

我当然可以在不使用-device virtio-9p-pci选项的情况下运行,但是我没有共享的hshare文件夹

使用以下命令创建zso.img:

qemu-img create -f qcow2 -o backing_file=zso.img zso_cow.img
Run Code Online (Sandbox Code Playgroud)

其中zso.img是Debian映像

ubuntu debian qemu virtual-machine

2
推荐指数
1
解决办法
1884
查看次数

Haskell StateT和ExceptT链

我不是很好的哈斯克尔程序员.我的任务是在我的大学编写一个编译器,我选择了haskell,因为它是用于此目的的好工具.我使用monads StateT和ExcepT,所以我有类型:

type Runner r s = StateT s (ExceptT LatteError IO) r
type RT r s = IO (Either LatteError (r, s))
Run Code Online (Sandbox Code Playgroud)

我用它创建walk一个程序树并生成asm代码,它可以按我的意愿工作.作为在树上行走的主要功能我使用

rProgram :: Program -> Runner [String] CompileState
Run Code Online (Sandbox Code Playgroud)

并解压缩结果我使用的功能

runR program = runExceptT (runStateT (rProgram program) initialCompileState)
Run Code Online (Sandbox Code Playgroud)

我想要做的不是有一些验证器,如类型检查,身份存在检查,我知道写它们.让我告诉我

tcProgram :: Program -> Runner () TypeCheckState
ieProgram :: Program -> Runner () IdentExistanceState
Run Code Online (Sandbox Code Playgroud)

我想以优雅的方式运行它们,并且throwError指示失败.如何把像他们这样的很多功能放在一起?

monads haskell monad-transformers

0
推荐指数
1
解决办法
213
查看次数