Connect Django to your Mysql Database

Assuming you’re on a *nux system, update your site’s settings.py file with the following:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'OPTIONS' : {
            'read_default_file': '/etc/mysql/my.cnf',
        }
    }
 }

Naturally, you’ll need to create or update your my.cnf file in the /etc/mysql directory.  For my needs, I had to add the following to my.cnf:

[client]
database = put your database name here
user = put your database user name here
password = put this database user's password here
default-character-set = utf8

AOMEI Partition Assistant Standard Edition

I installed a larger SSD in my Windows 10 laptop, but when I copied the old system disk to the new SSD, it retained the smaller partition size. I found that AOMEI Partition Assistant Standard Edition
would let me move disk partitions and then join the system partition with the unallocated space. All it in, this free disk partitioning software took about two minutes — including the reboot of my machine — to give me another 600GB of disk space on my system partition. I couldn’t be happier and I fully recommend AOMEI Partition Assistant Standard Edition. The free standard edition will do what you need it to do.

Macrium Reflect is free Windows 10 system disk cloning software

Macrium Reflect is truly free software for cloning a Windows 10 system drive. Requires registration to download and run the software, but doesn’t appear to cost anything. Had to run through a few utilities that straight up lied about being free before finding Macrium Reflect. So I wanted to give the software props for not just being a free disk cloning utility, but a great one that’s truly free. (I’m writing this post on the machine that’s using the newly cloned disk.)

PC World seems to agree.

Better way to write unit tests with Spring Boot

Basic template for writing the integration tests in springboot. the sql group is additional annotation. When ever you want to execute the particular sql queries before and after method run so u can use @SqlGroup annotation.

 @RunWith(SpringJUnit4ClassRunner.class)
 @SpringBootTest(classes = MainApplication.class,
 webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
 @SqlGroup({
 @Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD,
 scripts = "classpath:beforeTestRun.sql"),
 @Sql(executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD,
 scripts = "classpath:afterTestRun.sql")})

 public class CustomerControllerIntTest {}

See this StackOverflow answer

Autowiring Property Files using Spring

It’s often the case that credentials and URLs of external services need to be accessible in your application. These values can’t be stored in your version control for security reasons. One solution is to put the values in a Java properties file, store only a template for that file in your version control, and put the actual properties file on your installed instance.

Here’s how to access the properties file values in your Java code using Spring configuration:

@Configuration
@PropertySource("classpath:that-api.properties")
public class ThatApiProperties {

    @Value("${login}")
    private String login;

    @Value("${password}")
    private String password;

    @Value("${uri}")
    private String uri;

    public String getLogin() {
        return this.login;
    }

    public String getPassword() {
        return this.password;
    }

    public String getUri() {
        return this.uri;
    }
}

The properties file for this example needs to be in your project directory in the following subdirectory:

src/main/resources/that-api-TEMPLATE.properties

During your build process, you’ll create a version of this file with the sensitive values plugged in and save it to

src/main/resources/that-api.properties