I know this is an old threat, but I found this to be the only relevant 
conversation regarding this error.

In my case, I'm loading the models (requiring the model class files) in a 
Sinatra app, at the config.ru bootstrap stage. The actual connection to the 
database is handled from within the app, which is initialized after rackup 
runs though the config.ru file. Thus, the models are loaded prior to the db 
connection.

I came across this when upgrading Sequel from version 3.30.0 to 3.42.0. 
Previously (at least as of 3.30.0), models did not complain about being 
loaded prior to database connection, so why the change now? Any way to 
disable this behavior (other than sticking to older versions of Sequel)?



On Saturday, April 28, 2012 12:15:37 PM UTC-7, Jeremy Evans wrote:
>
> On Saturday, April 28, 2012 10:38:53 AM UTC-7, John wrote:
>>
>> Hi Jeremy,
>>
>> Thank you for the fast reply, will try this out later today.
>>
>> I want to load the models before opening the database connection for my 
>> Address Book importer script. The idea is to allow people to upload their 
>> Address Book archives through an upload form. This means the database 
>> doesn't exist yet when the code is loaded, it's an SQLite database 
>> contained in the archive that is uploaded. The schema is known but the 
>> database itself isn't available yet.
>>
>>
> For something like this, there are a few possibilities that come to mind:
>
> 1) Connect to an empty database with the same schema before loading the 
> models, then call db= on the related models later to change the database.
>
> 2) Use the sharding support, with add_servers and Database#disconnect to 
> change the actual database.
>
> 3) Create separate model subclasses for each database connection.
>
> 4) Don't use models at all, use plain datasets.
>
> Jeremy
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sequel-talk/-/Wtu5OydF7wcJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to