Best practices for persistent database connections in Python when using Flask

Turns out there is a straightforward way to achieve what I was after. But as the commenters suggested, if it is at all possible to go the flask sqlalchemy route, then you might want to go that way. My approach to solving the problem is to save the connection object in a module level variable … Read more

SQL Express connection string: mdf file location relative to application location

Thanks everyone, I used a combination of your responses. In my app.config file my connection string is defined as follows <add name=”MyConnectionString” connectionString=”Server=.\SQLExpress;AttachDbFilename=|DataDirectory|\MyDatabase.mdf;Database=MyDatabaseForTesting;Trusted_Connection=Yes;” /> In my unit test class I set the DataDirectory property using the following [TestInitialize] public void TestInitialize() { AppDomain.CurrentDomain.SetData(“DataDirectory”, System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, “Databases”)); // rest of initialize implementation … }

How can I access Oracle from Python?

Here’s what worked for me. My Python and Oracle versions are slightly different from yours, but the same approach should apply. Just make sure the cx_Oracle binary installer version matches your Oracle client and Python versions. My versions: Python 2.7 Oracle Instant Client 11G R2 cx_Oracle 5.0.4 (Unicode, Python 2.7, Oracle 11G) Windows XP SP3 … Read more

Enable tcp\ip remote connections to sql server express already installed database with code or script(query)

I tested below code with SQL Server 2008 R2 Express and I believe we should have solution for all 6 steps you outlined. Let’s take on them one-by-one: 1 – Enable TCP/IP We can enable TCP/IP protocol with WMI: set wmiComputer = GetObject( _ “winmgmts:” _ & “\\.\root\Microsoft\SqlServer\ComputerManagement10”) set tcpProtocols = wmiComputer.ExecQuery( _ “select * … Read more

What is the difference between maxActive vs. maxIdle for Tomcat connection pools?

maxActive is straight forward. maxIdle can be explained in this way – say you have 100 max Active connections and say you set maxIdle to 80. Assuming there are no requests going to the database, only 80 connections will be tested (via the validationquery) and will stay active. The other 20 will be closed. So … Read more

Creating a new database and new connection in Oracle SQL Developer

This tutorial should help you: Getting Started with Oracle SQL Developer See the prerequisites: Install Oracle SQL Developer. You already have it. Install the Oracle Database. Download available here. Unlock the HR user. Login to SQL*Plus as the SYS user and execute the following command: alter user hr identified by hr account unlock; Download and … Read more