当前位置: 动力学知识库 > 问答 > 编程问答 >

python-tarantool call parameters

问题描述:

I want to call box.space.auth_user:auto_increment{"8", 7, 7, 7} from python script.

This is what I do in python

import tarantool

connection = tarantool.connect('127.0.0.1', 3303)

connection.call('box.space.auth_user:auto_increment', ("8", 7, 7, 7))

And then I get the error:

[string "-- schema.lua (internal file)..."]:921: bad argument #1 to 'insert' (table expected, got string)

This is how I define my auth_user schema

box.schema.space.create('auth_user',{if_not_exists=true})

box.space.auth_user:create_index('primary', {type='TREE', if_not_exists=true, unique=true, parts={1,'NUM'}})

box.space.auth_user:create_index('login', {type='HASH', if_not_exists=true, unique=true, parts={2,'STR'}})

What am I doing wrong?

网友答案:

It's not a bug, please use [["8", 7, 7, 7]] or (("8", 7, 7, 7), ).

In [4]: connection.call('box.space.auth_user:auto_increment', [["8", 7, 7, 7]])
Out[4]:
- [1, '8', 7, 7, 7]

tarantool-python uses array to show that it's arguments, so it was analog for box.space.auth_user:auto_increment("8", 7, 7, 7), not {}

分享给朋友:
您可能感兴趣的文章:
随机阅读: