Python Orator ORM模型创建方法无效SQL

Python Orator ORM模型创建方法无效SQL,python,orm,relational-database,Python,Orm,Relational Database,我有一个通过迁移创建的数据库。我的一张桌子看起来像这样 def create_customer_table(self): with self.schema.create("customer") as table: table.char("name",120).unique() table.integer("transmitting_hours").default(24) #how many hours after transmission vehi

我有一个通过迁移创建的数据库。我的一张桌子看起来像这样

def create_customer_table(self):
        with self.schema.create("customer") as table:
        table.char("name",120).unique()
        table.integer("transmitting_hours").default(24) #how many hours after transmission vehicle is considered transmitting
        table.boolean("is_tpms").default(False)
        table.boolean("is_dor").default(False)
        table.boolean("is_otr").default(False)
        table.boolean("is_track_and_trace").default(False)
        table.char("contact_person",25)
        table.char("created_by",25)
        table.enum("temperature_unit",TEMP_UNITS)
        table.enum("pressure_unit",PRESSURE_UNITS)
        table.enum("distance_unit",DISTANCE_UNITS)
        table.char("time_zone",25)
        table.char("language",2)
        table.timestamps()
我有一个非常简单的ORM模型

class Customer(Model):
     __table__ = "customer"
     __timestamps__ = False
     __primary_key__ = "name"
     __fillable__ = ['*']
然后,我尝试使用以下代码进行基本插入

def add_sample_customer():
    sample_customer = {}
    sample_customer["name"] = "customer_2"
    sample_customer["contact_person"] = "Abradolf"
    sample_customer["created_by"] = "Frodo"
    sample_customer["time_zone"] = "GMT-5"
    sample_customer["language"] = "EN"
    sample_customer["temperature_unit"] = "FAHRENHEIT"
    sample_customer["pressure_unit"] = "PSI"
    sample_customer["distance_unit"] = "MI"
    customer_model = Customer.create(_attributes = sample_customer)
我从这段代码中得到的异常如下

orator.exceptions.query.QueryException: syntax error at or near ")"
LINE 1: INSERT INTO "customer" () VALUES () RETURNING "name"                               
(SQL: INSERT INTO "customer" () VALUES () RETURNING "name" ([]))
看来演说家并没有填补这里的空缺。我还尝试了几种不同的语法方法,使用**sample_customer将dict放入其中,也只是直接将dict放入其中,但都不起作用,所有这些方法都有一个例外。我从orator库中打印内容开始调试,但还没到任何地方

如果我单独进行模型属性赋值并使用model.save()方法,则插入可以工作

def add_sample_customer():
    sample_customer = {}
    sample_customer["name"] = "customer_2"
    sample_customer["contact_person"] = "Abradolf"
    sample_customer["created_by"] = "Frodo"
    sample_customer["time_zone"] = "GMT-5"
    sample_customer["language"] = "EN"
    sample_customer["temperature_unit"] = "FAHRENHEIT"
    sample_customer["pressure_unit"] = "PSI"
    sample_customer["distance_unit"] = "MI"
    customer_model = Customer()
    for k,v in sample_customer.items():
        setattr(customer_model,k,v)
    customer_model.save()

有人知道model.create()语法失败的原因吗?

我想答案是: 只需传递字典,而不使用带有属性的关键字表示法:

Customer.create(sample_customer) 


哪些是有效的符号

是否
customer\u model=customer.create(**sample\u customer)
起作用?这将产生与上述空insert语句相同的异常。
Customer.create(attribute=value,attribute2=value2,..etc)