Sublime Forum

How to keep a database connection?

#1

I am using SQLite database for my Sublime Text plugin. Currently each command opens the database file to create a new connection. This is working fine but i wonder if it is a good solution.

Is there a better way to share a database connection with Sublime Text commands? In theory i’d only need to open a connection for plugin_loaded() and its cursor for my commands. But of course i cannot pass the connection to my commands to commit a query.

0 Likes

#2

just make the connection a global variable?

0 Likes

#3

I think that’s fine. It’s not like you’re running such commands tens of times per second, no?

1 Like