小编Moj*_*aba的帖子

如何在没有rootfs的情况下创建LXC容器

我想在lxc 1.0.5和Ubuntu 14.04中创建一个没有"rootfs"的容器.

我之前在lxc的早期版本中做过.在以前的版本中,如果我们使用不带"-t"选项的lxc-create,它将创建一个没有"rootfs"的容器.

所以我尝试:

lxc-create -n foo
Run Code Online (Sandbox Code Playgroud)

我收到了这个错误:

lxc_container: Error creating container foo
Run Code Online (Sandbox Code Playgroud)

我阅读了新的lxc-create手册页.新的联机帮助页说:

       -t template
              'template' is the short name of an existing 'lxc-template'
              script that is called by lxc-create, eg. busybox, debian,
              fedora, ubuntu or sshd.  Refer to the examples in
              /usr/local/share/lxc/templates for details of the expected
              script structure.  Alternatively, the full path to an
              executable template script can also be passed as a parameter.
              "none" can be used to force lxc-create to skip rootfs …

lxc

7
推荐指数
1
解决办法
3463
查看次数

在"declarative_base()"中获取最后插入的记录的主键

我想获得最后插入的主键,我已经知道两种方式:

1)"lastrowid"与"原始SQL"

from sqlalchemy import create_engine, MetaData, Table, Column, Integer, String, text

engine = create_engine('sqlite://')

meta = MetaData()

tbl = Table('tbl', meta,
    Column('f1', Integer, primary_key=True),
    Column('f2', String(64))
)

tbl.create(engine)

sql = text("INSERT INTO tbl VALUES (NULL, 'some_data')")
res = engine.execute(sql)

print(res.lastrowid)
Run Code Online (Sandbox Code Playgroud)

2)"inserted_primary_key",带有"insert()"

from sqlalchemy import create_engine, MetaData, Table, Column, Integer, String

engine = create_engine('sqlite://')

meta = MetaData()

tbl = Table('tbl', meta,
    Column('f1', Integer, primary_key=True),
    Column('f2', String(64))
)

tbl.create(engine)

ins = tbl.insert().values(f2='some_data')
res = engine.execute(ins)

print(res.inserted_primary_key)
Run Code Online (Sandbox Code Playgroud)

但我的问题是"declarative_base()"

from …
Run Code Online (Sandbox Code Playgroud)

python sqlalchemy

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

标签 统计

lxc ×1

python ×1

sqlalchemy ×1