If it is SQLite (it looks like MySQL) then the syntax for the auto key is:
query.exec("create table przedmioty(id integer primary key, nazwa varchar(40), skrot varchar(10))");
query.exec("create table przedmioty(id integer primary key, nazwa varchar(40), skrot varchar(10))");
To copy to clipboard, switch view to plain text mode
or
query.exec("create table przedmioty(id integer primary key autoincrement, nazwa varchar(40), skrot varchar(10))");
query.exec("create table przedmioty(id integer primary key autoincrement, nazwa varchar(40), skrot varchar(10))");
To copy to clipboard, switch view to plain text mode
SQLite is very particular about the form of the id column declaration.
This is what Sqlite makes of these options:
SQLite version 3.6.23.1
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table przedmioty(id int auto_increment not null primary key, nazwa varchar(40), skrot varchar(10));
sqlite> insert into przedmioty (skrot, nazwa) values ('test', 'test');
Error: przedmioty.id may not be NULL
sqlite> drop table przedmioty;
sqlite> create table przedmioty(id integer primary key, nazwa varchar(40), skrot varchar(10));
sqlite> insert into przedmioty (skrot, nazwa) values ('test', 'test');
sqlite> insert into przedmioty (skrot, nazwa) values ('test', 'test');
sqlite> select * from przedmioty;
1|test|test
2|test|test
sqlite> drop table przedmioty;
sqlite> create table przedmioty(id integer primary key autoincrement, nazwa varchar(40), skrot varchar(10));
sqlite> insert into przedmioty (skrot, nazwa) values ('test', 'test');
sqlite> insert into przedmioty (skrot, nazwa) values ('test', 'test');
sqlite> select * from przedmioty;
1|test|test
2|test|test
sqlite>
SQLite version 3.6.23.1
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table przedmioty(id int auto_increment not null primary key, nazwa varchar(40), skrot varchar(10));
sqlite> insert into przedmioty (skrot, nazwa) values ('test', 'test');
Error: przedmioty.id may not be NULL
sqlite> drop table przedmioty;
sqlite> create table przedmioty(id integer primary key, nazwa varchar(40), skrot varchar(10));
sqlite> insert into przedmioty (skrot, nazwa) values ('test', 'test');
sqlite> insert into przedmioty (skrot, nazwa) values ('test', 'test');
sqlite> select * from przedmioty;
1|test|test
2|test|test
sqlite> drop table przedmioty;
sqlite> create table przedmioty(id integer primary key autoincrement, nazwa varchar(40), skrot varchar(10));
sqlite> insert into przedmioty (skrot, nazwa) values ('test', 'test');
sqlite> insert into przedmioty (skrot, nazwa) values ('test', 'test');
sqlite> select * from przedmioty;
1|test|test
2|test|test
sqlite>
To copy to clipboard, switch view to plain text mode
Bookmarks