Row not inserted into table when using CompositeKey
Try reading
http://peewee.readthedocs.org/en/latest/peewee/models.html#non-integer-primary-keys
On Jun 14, 2014 2:56 PM, "scls19fr" notifications@github.com wrote:

> Hello,
> 
> I'm new to Peewee.
> 
> I did this code:
> 
> from peewee import *
> 
> db = SqliteDatabase('json_rpc.sqlite')
> 
> class RPC(Model):
>     terminal_id = CharField()
>     request_id = CharField()
>     request = CharField()
>     response = CharField()
> 
> ```
> class Meta:
>     database = db
>     primary_key = CompositeKey('terminal_id', 'request_id')
> ```
> 
> # connect to our database
> 
> db.connect()
> 
> RPC.create_table()
> 
> terminal_id = 'test01'
> request_id = 2
> request = '{"jsonrpc": "2.0", "method": "subtract", "params": [42, 23], "id": '+ str(request_id) + '}'
> response = ""
> rpc = RPC(
>     terminal_id=terminal_id,
>     request_id = request_id,
>     request=request,
>     response=response
> )
> rpc.save()
> 
> Unfortunatelly row is not inserted into SQLite database (without any
> error).
> 
> If I comment primary_key = CompositeKey('terminal_id', 'request_id')
> row is inserted (but there is no security to ensure that there is a unique
> couple (terminal_id, request_id)).
> 
> So I don't know if this is really an issue or a misunderstanding from my
> side.
> 
> Kind regards
> 
> —
> Reply to this email directly or view it on GitHub
> https://github.com/coleifer/peewee/issues/374.
 Thanks for the tip
`rpc.save(force_insert=True)` fixes my problem

Hello,

I'm new to Peewee.

I did this code:

```
from peewee import *

db = SqliteDatabase('json_rpc.sqlite')

class RPC(Model):
    terminal_id = CharField()
    request_id = CharField()
    request = CharField()
    response = CharField()

    class Meta:
        database = db
        primary_key = CompositeKey('terminal_id', 'request_id')

# connect to our database
db.connect()

RPC.create_table()

terminal_id = 'test01'
request_id = 2
request = '{"jsonrpc": "2.0", "method": "subtract", "params": [42, 23], "id": '+ str(request_id) + '}'
response = ""
rpc = RPC(
    terminal_id=terminal_id,
    request_id = request_id,
    request=request,
    response=response
)
rpc.save()
```

Unfortunatelly row is not inserted into SQLite database (without any error).

If I comment `primary_key = CompositeKey('terminal_id', 'request_id')`
row is inserted (but there is no security to ensure that there is a unique couple (terminal_id, request_id)).

So I don't know if this is really an issue or a misunderstanding from my side.

Kind regards
