On Friday, November 15, 2019 at 2:02:51 PM UTC-5, ajoeiam wrote: > > If I want a connection to the database but want it for only the time > the customer (query source) is logged in - - - how do I specify that? > (So I don't want the connection to be timed - - - would rather the > connection was related to the online access and then closed when the > client (customer) logged off.) >
I don't think there's a way to do that. If you're trying to use one DB connection per short-lived request, the way ordinary Django request handlers do when CONN_MAX_AGE is disabled, then simply bundle all your database queries into one synchronous function and decorate it with database_sync_to_async(). If you actually want to maintain *one database connection per websocket*, then don't use Channels. The whole point of Channels is to *not* consume a thread per websocket. A database connection is a thread (on the database server). You won't find much help online if you're trying to tie up a database connection per Websocket. I found an exception: an academic project from some University of Alberta students. https://github.com/Kai-Bailey/WebSock. It's not Django. Enjoy life, Adam -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c1082698-3b73-4058-a809-fffb5daf6a2b%40googlegroups.com.