Re: [sqlite] Article about using sqlite3 in Python

2017-10-23 Thread Keith Medcalf
According to the documentation, it is the cache_statements keyword to the sqlite3 connect function: The sqlite3 module internally uses a statement cache to avoid SQL parsing overhead. If you want to explicitly set the number of statements that are cached for the connection, you can set the

Re: [sqlite] very sqlite3 noobie error

2017-10-23 Thread dave
> -Original Message- > From: sqlite-users > [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On > Behalf Of John R. Sowden > Sent: Sunday, October 22, 2017 9:59 PM ... > Since I am trying to learn sqlite3 (unlearning foxpro) I find that > python is the simpleist language, wfich

Re: [sqlite] Article about using sqlite3 in Python

2017-10-23 Thread E.Pasma
22 okt 2017, 18:47, Simon Slavin: I don’t know enough about Python to evaluate this, but the sqlite3 side is sound, and some readers might find it useful. Simon. It is written very well. However for readers with an

Re: [sqlite] How to create primary key from two another PK's?

2017-10-23 Thread Don V Nielsen
Just asking some leading questions. You have students. And students have work pieces. You are then creating a list "uniqueworkpiece" showing the work pieces associated to each student. Your primary key will ensure the uniqueness of the student to work piece. Do you also need to ensure that the

Re: [sqlite] How to create primary key from two another PK's?

2017-10-23 Thread Simon Slavin
SQLite does not support VARCHAR(2). All fields declared like that are TEXT and SQLite pays no attention to the length of the text. Declare them as TEXT. SQLite does not support TINYINT All fields declared like that are INTEGER. Declare them as INTEGER. Your TEXT NOT NULL fields should be

Re: [sqlite] Article about using sqlite3 in Python

2017-10-23 Thread David Raymond
How does one enable or disable statement caching then? For something as basic as just inserting integers executemany is about 3 times faster. Python version: 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)] Python sqlite3 module version: 2.6.0 sqlite3.dll version:

Re: [sqlite] How to create primary key from two another PK's?

2017-10-23 Thread csanyipal
So here it is: CREATE TABLE IF NOT EXISTS student ( id INTEGER CONSTRAINT pk_student PRIMARY KEY AUTOINCREMENT, idnum INTEGER UNIQUE NOT NULL COLLATE NOCASE, studentname TEXT NOT NULL COLLATE NOCASE, teachinglang TEXT NOT NULL COLLATE NOCASE, grade INTEGER, classname TEXT NOT NULL,

[sqlite] PRAGMA page_size = 8192 may be cause leak

2017-10-23 Thread Kent Carlson
When running this program with Apple's Instruments memory profiler leaks are reported when the tree is balanced, stack crawls are related to the page cache. 1 sqlite3memtest sqlite3MemMalloc /KentDev/sqlite3memtest/sqlite3memtest/sqlite3.c:21312 2 sqlite3memtest mallocWithAlarm

Re: [sqlite] How to create primary key from two another PK's?

2017-10-23 Thread Richard Damon
On 10/23/17 12:26 PM, Simon Slavin wrote: On 23 Oct 2017, at 4:25pm, csanyipal wrote: I will in the 'student' table allow an 'id' INTEGER PRIMARY KEY AUTOINCREMENT . Every student have an identification number and such a number is 13 digit long. But some idnumber start

Re: [sqlite] How to create primary key from two another PK's?

2017-10-23 Thread csanyipal
I added CASCADE, like this: CREATE TABLE IF NOT EXISTS "student" ( "id" INTEGER CONSTRAINT "pk_student" PRIMARY KEY AUTOINCREMENT, "idchr" TEXT UNIQUE NOT NULL COLLATE NOCASE, "studentname" TEXT NOT NULL COLLATE NOCASE, "teachinglang" TEXT NOT NULL COLLATE NOCASE, "grade" INTEGER,

Re: [sqlite] Article about using sqlite3 in Python

2017-10-23 Thread David Raymond
Basic but good. execute will prepare the statement each time through, whereas executemany will prepare once and then just bind for each run through, which is where the time saving comes from. Depending on how complex what you're doing is though it can be hard, or more often awkward to create an

Re: [sqlite] How to create primary key from two another PK's?

2017-10-23 Thread csanyipal
> SQLite does not support VARCHAR(2). All fields declared like that are > TEXT and SQLite pays no attention to the length of the text. Declare them > as TEXT. > > SQLite does not support TINYINT All fields declared like that are > INTEGER. Declare them as INTEGER. > > Your TEXT NOT NULL

Re: [sqlite] [EXTERNAL] xRowid and read only virtual tables....

2017-10-23 Thread Hick Gunter
If your xBestIndex function indicates that your virtual table supports an index on the constraint with cost x and you have a single OR clause, the QP will assign a cost of 2*x to performing 2 keyed lookups/partial table scans If your XbestIndex function indicates that your virtual tabel does no

Re: [sqlite] very sqlite3 noobie error

2017-10-23 Thread Simon Slavin
On 23 Oct 2017, at 5:24am, John R. Sowden wrote: > i think there are too many errors in this guide for me to use it. The guide is fine. You made mistakes when you copied it. You should be able to copy and past the text straight from the page:

Re: [sqlite] How to create primary key from two another PK's?

2017-10-23 Thread csanyipal
I modified my database so it is now like: BEGIN TRANSACTION; CREATE TABLE IF NOT EXISTS "student" ( "id" INTEGER CONSTRAINT "pk_student" PRIMARY KEY AUTOINCREMENT, "idchr" TEXT UNIQUE NOT NULL COLLATE NOCASE, "studentname" TEXT NOT NULL COLLATE NOCASE, "teachinglang" TEXT NOT NULL COLLATE

Re: [sqlite] How to create primary key from two another PK's?

2017-10-23 Thread Simon Slavin
On 23 Oct 2017, at 4:25pm, csanyipal wrote: > I will in the 'student' table allow an 'id' INTEGER PRIMARY KEY > AUTOINCREMENT . > Every student have an identification number and such a number is 13 digit > long. But some idnumber start with leading zero so I think to it is

Re: [sqlite] Article about using sqlite3 in Python

2017-10-23 Thread Damien Sykes-Lindley
Hi David, Very useful regarding the SQLite updating procedure. I was looking in lib or wherever the Python SQLite bindings are, but all I could find there was sqlite3.pyd. As for executemany, I personally use executescript which then allows me to use begin/commit statements which also saves a

Re: [sqlite] How to create primary key from two another PK's?

2017-10-23 Thread csanyipal
Don V Nielsen wrote > Just asking some leading questions. You have students. And students have > work pieces. You are then creating a list "uniqueworkpiece" showing the > work pieces associated to each student. Your primary key will ensure the > uniqueness of the student to work piece. > > Do you

Re: [sqlite] Article about using sqlite3 in Python

2017-10-23 Thread Keith Medcalf
On Monday, 23 October, 2017 08:36, David Raymond wrote: NB: References to pysqlite2 refer to the builtin sqlite3 wrapper in python. This wrapper was called pysqlite2 long before it was included in the standard library. It is still updated to fix bugs and