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

#4

To be honest, I have never used the Sublime Text plugin to interact with the database, so I can’t recommend a better solution. But I can assume that your database will function without problems, as long as you don’t create too many queries. Why use Sublime Text if you can connect a database using PHP? With PHP, you can interact with the database as you like. You can add data, delete data, even change data. At the same time, using oracle visual studio, everything becomes even more convenient at times.

0 Likes