R
R
Radiss2020-11-21 04:41:28
Python
Radiss, 2020-11-21 04:41:28

Error with SQL when starting a bot in telegram - how to solve it?

Why in the 'status' column, if I set the values:

status BOOLEAN NOT NULL
DEFAULT (TRUE)

then when starting the telegram does not respond to the commands '/subscribe' , '/unsubscibe'

In a tabular form, the status is '1'

In the console

sqlite3.DatabaseError: malformed database schema (subscriptions) - default value of column [status] is not constant


But if I remove the 'default' value, then the bot responds to commands, but the status does not change to '0' after 'unsubscribe'

CREATE TABLE subscriptions (
    id      INTEGER       PRIMARY KEY AUTOINCREMENT,
    user_id VARCHAR (255) NOT NULL,
    status  BOOLEAN       NOT NULL
);

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
galaxy, 2020-11-21
@galaxy

Run sqlite, open your database and type in the console

.schema subscriptions

insert into subscriptions (user_id) values ('a');
insert into subscriptions (user_id, status) values ('b', true);

And see if everything goes right (I suspect that the table definition doesn't look like what you show after all)

H
Hranutel, 2021-10-02
@Hranutel

Open your database, click Edit column and select the column in which record status you want.
Stepping on the button in Default, press Configure and type in ('TRUE').
Save changes in tables.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question