Change default number of attached databases

Just starting out? Need help? Post your questions and find answers here.
User avatar
Columbo
Enthusiast
Enthusiast
Posts: 303
Joined: Wed Sep 10, 2014 7:17 am
Location: Ontario Canada
Contact:

Change default number of attached databases

Post by Columbo »

It seems that SQLite allows 125 databases to be attached however, the default is 10. How do you change this default value to something slightly higher?

Thanks
http://www.oldtimeradiotoday.com - Listen to or download classic old time radio broadcasts.
percy_b
User
User
Posts: 72
Joined: Mon Jan 12, 2015 10:25 am

Re: Change default number of attached databases

Post by percy_b »

Columbo wrote:It seems that SQLite allows 125 databases to be attached however, the default is 10. How do you change this default value to something slightly higher?

Thanks
Hi,

I may be wrong, but I believe that is a compile-time limitation. However, you can lower the number of connected databases by calling "sqlite3_limit".

Sent from my Moto E (4) using Tapatalk
User avatar
Columbo
Enthusiast
Enthusiast
Posts: 303
Joined: Wed Sep 10, 2014 7:17 am
Location: Ontario Canada
Contact:

Re: Change default number of attached databases

Post by Columbo »

I want to increase the number higher than 10. I'm not sure how to do this or what the syntax would be if it is a compile-time limitation?
http://www.oldtimeradiotoday.com - Listen to or download classic old time radio broadcasts.
percy_b
User
User
Posts: 72
Joined: Mon Jan 12, 2015 10:25 am

Re: Change default number of attached databases

Post by percy_b »

Columbo wrote:I want to increase the number higher than 10. I'm not sure how to do this or what the syntax would be if it is a compile-time limitation?
You will need to re-compile the Sqlite source code and increase the value for the SQLITE_MAX_ATTACHED manifest constant. By default, it is set to 10.

Sent from my Moto E (4) using Tapatalk
User avatar
Columbo
Enthusiast
Enthusiast
Posts: 303
Joined: Wed Sep 10, 2014 7:17 am
Location: Ontario Canada
Contact:

Re: Change default number of attached databases

Post by Columbo »

You will need to re-compile the Sqlite source code and increase the value for the SQLITE_MAX_ATTACHED manifest constant. By default, it is set to 10.
Where do I find the SQLite source and what compiler is it compiled with? I thought that SQLite was installed with PB?
http://www.oldtimeradiotoday.com - Listen to or download classic old time radio broadcasts.
percy_b
User
User
Posts: 72
Joined: Mon Jan 12, 2015 10:25 am

Re: Change default number of attached databases

Post by percy_b »

Columbo wrote:
You will need to re-compile the Sqlite source code and increase the value for the SQLITE_MAX_ATTACHED manifest constant. By default, it is set to 10.
Where do I find the SQLite source and what compiler is it compiled with? I thought that SQLite was installed with PB?
SQLite is built into PureBasic. However, if you wish to customize SQLite, you will need to modify the canonical source code. You will also need a C compiler. You can get more information about that here:

https://SQLite.org/getthecode.html
https://SQLite.org/howtocompile.html

If you want to use the above approach, you will most likely have to use SQLite as a dll.

Sent from my Moto E (4) using Tapatalk
Last edited by percy_b on Wed Jun 05, 2019 11:02 pm, edited 1 time in total.
User avatar
Columbo
Enthusiast
Enthusiast
Posts: 303
Joined: Wed Sep 10, 2014 7:17 am
Location: Ontario Canada
Contact:

Re: Change default number of attached databases

Post by Columbo »

Thank you for your help. I don't know why they allow 125 attachments but set it to default to 10 and then make it so difficult to change the default.

It would be great if you could just use something like this in Purebasic:

Code: Select all

UseSQLiteDatabase()
Set SQLITE_MAX_ATTACHED = 18
Oh well, I guess I'll have to find another way to handle this problem.

Thanks again.
http://www.oldtimeradiotoday.com - Listen to or download classic old time radio broadcasts.
User avatar
kpeters58
Enthusiast
Enthusiast
Posts: 341
Joined: Tue Nov 22, 2011 5:11 pm
Location: Kelowna, BC, Canada

Re: Change default number of attached databases

Post by kpeters58 »

Are you sure this is a real world problem?

Why would you want to attach to that many databases simultaneously? Remember, you can always detach and re-attach...
PB 5.73 on Windows 10 & OS X High Sierra
User avatar
Columbo
Enthusiast
Enthusiast
Posts: 303
Joined: Wed Sep 10, 2014 7:17 am
Location: Ontario Canada
Contact:

Re: Change default number of attached databases

Post by Columbo »

Why would you want to attach to that many databases simultaneously? Remember, you can always detach and re-attach...
It is for a recipe program which has a categories database with subcategories attached. I guess detaching and re-attaching is an option but it seemed much easier and less coding to be able to attach all of the subcategories.

Thanks for the suggestion. I'll play with it a bit.
http://www.oldtimeradiotoday.com - Listen to or download classic old time radio broadcasts.
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4749
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Change default number of attached databases

Post by Fangbeast »

Columbo wrote:
Why would you want to attach to that many databases simultaneously? Remember, you can always detach and re-attach...
It is for a recipe program which has a categories database with subcategories attached. I guess detaching and re-attaching is an option but it seemed much easier and less coding to be able to attach all of the subcategories.

Thanks for the suggestion. I'll play with it a bit.
I might have missed your point but why do the categories need to be in another database? I wrote a recipe manager years ago with a lot of help (as usual) and the categories are in the same database but a separate table in the same database. They don't need another database to function and none of the commercial programs do it that way.

I analysed Living Cookbook, Paprika and Mastercook's databases and their their related tables are in the one database and joined by queries.

Just wondering.
Amateur Radio, D-STAR/VK3HAF
User avatar
kpeters58
Enthusiast
Enthusiast
Posts: 341
Joined: Tue Nov 22, 2011 5:11 pm
Location: Kelowna, BC, Canada

Re: Change default number of attached databases

Post by kpeters58 »

I am with Fangbeast on this one:

These should be different tables in the same database...
PB 5.73 on Windows 10 & OS X High Sierra
User avatar
skywalk
Addict
Addict
Posts: 3999
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Change default number of attached databases

Post by skywalk »

I have use cases where attached db's approach 10 or 12. It should default to a higher count. But, we can now recompile with all our custom settings and choose the resulting dll in usesqlitedatabase().
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Post Reply