Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increasing Limit of Attached Databases in SQLite from PDO

Tags:

php

sqlite

pdo

I'm working on a project that should benefit greatly from using one database file per each table, mostly because I'm trying to avoid having the database grow too large but also because of file locking issues.

I thought of using the ATTACH statement to have a "virtual" database with all my tables, but I just found out that while the upper limit of attached databases is 62 (which would be totally acceptable for me), the default limit of attached databases is in fact 10, from the SQLite limits page:

Maximum Number Of Attached Databases

The ATTACH statement is an SQLite extension that allows two or more databases to be associated to the same database connection and to operate as if they were a single database. The number of simultaneously attached databases is limited to SQLITE_MAX_ATTACHED which is set to 10 by default. The code generator in SQLite uses bitmaps to keep track of attached databases. That means that the number of attached databases cannot be increased above 62.

Since I will need to support more than 10 tables, my question is, how do I set the SQLITE_MAX_ATTACHED variable to a higher value from PHP (using PDO with SQLite 3)?

like image 953
Alix Axel Avatar asked Oct 21 '22 08:10

Alix Axel


1 Answers

These limits are compile-time options.

You must recompile PHP to change them.

like image 186
CL. Avatar answered Oct 27 '22 09:10

CL.