Connect MySQL db using Powershell

The purpose of this blog is to get the dev aware of how the PowerShell can be used to connect to MySQL db and insert a sample record.

With the increase of automation in industry, powershell is made responsible for doing many more things including inserting a new record in MySQL database.

The script flow start  at line 28 by setting bthe username/ password/ database name, server name of the MYSQL database. By Default the port to connect db is 3306.
$query parameter of powershell need to be set for correct insert DML statement.
Next is Powershell function call which takes username, password, server, database, query as parameter. Line 1 to 26 is PowerShell function which handles this.

For this function to work perfectly it necessary for[reflection.assembly]::LoadFrom(“C:\abc\MySql.Data.dll”)

Statement to execute with success. What this statement do is load MySQL.data.dll assembly in script.

Its >net and MySQL connector Dll. You can get this dll by creating a new project in .Net Visual studio and add a new package by searching ‘MySQL’. Make sure you correctly set this DLL path in script.
This function takes care of establishing the connection with MySQL, Open the connection, execute the SQL DML query and return the response.
I tested this script in Windows 10, Powershell 4 and MySQL 8.4.5 and works fine.
The script can be downloaded from: https://1drv.ms/u/s!AuanYRI1Vj_XgyHzrT3AlobAor2a
Advertisements

App services vs Cloud Services vs VM

Found a useful diagram:

azure-services

at http://cloudacademy.com/blog/microsoft-azure-app-service-virtual-machines/

by

 

.Net framework version the assembly was created in

string assemblyPath = @”<exe/ dll path>”;

var assembly = Assembly.LoadFrom(assemblyPath);

var customAttributes = assembly.GetCustomAttributesData();

var dotnetFramework = customAttributes.FirstOrDefault(attr => attr.AttributeType.Equals(typeof(TargetFrameworkAttribute)));

var frameworkVersion = string.Empty;

if (null != dotnetFramework)

{

if (dotnetFramework.ConstructorArguments.Any())

{

// first argument is the name of the framework.

frameworkVersion = (string)dotnetFramework.ConstructorArguments[0].Value;

}

}

Console.WriteLine(“Framework Version: “ + frameworkVersion);

 

This code will give you the .Net framework version the dll/exe was created in.

 

I tested it for 4.5, 4.6.1 , 4.5.2 and gives the correct info.

 

ECMAScript 6 and Browsers support

We all know ECMAScript 6 was released in June 2015. Many new features made part of final edition of it. Work on ECMAScript 7 has started now.
Browsers are trst to implement these features assp.

https://en.wikipedia.org/wiki/ECMAScript Wikipedia
has good updates on where browsers stand. So far IE11 seems to be leading this race, followed by Chrome.

All web developers must read the ECMAScript specifications at: http://www.ecma-international.org/ecma-262/6.0/

Good Luck!

Running MSTest as 64 bit

Do you know the MsTest.exe is 32 bit by default. MS is yet to come up with 64 bit version of this exe, to run the tests in 64 bit mode.

Found the following steps in one of the useful post on Stackoverflow: http://stackoverflow.com/questions/5880337/run-tests-in-64-bit

1.Backup mstest.exe and run CorFlags.exe MSTest.exe /32BIT- /Force to remove the 32-bit flag
2.Run your tests with /noisolation: MSTest.exe /testcontainer: /resultsfile: /noisolation

Tried validate the 3 step from post on my windows 7 machine but could not be validated so skipping that.

VSTS get a glimpse Series-1

Hi all. It’s been a good 2 years since TFS services online were made available by Microsoft. So much has changed since then in and around the world as well as in the TFS services online features.

So I thought to again visit the portal and get a glimpse of what all are now available? Writing this blog which is a 10 post series covering all the major features available as on 20 Jan 2016.

By the way 2 weeks back Microsoft renamed it from VSO to VSTS (Visual Studio Team Services). To me this new name make the right step. The On-premise version can continue to be called as TFS.

Time to Explore VSTS……………

As a first step i used a new login account and got the URL for my portal as: https://hemantmahajan.visualstudio.com/

As soon as you open this URL, following contents are presented to you in browser: On the left bottom is a link to create a new project, so click ‘New’.

Fill the details required to create a new project. This include Project name, Description, Template type and Version control (TFVC or GIT)

It may take a while for VSTS to create a project for you.

Cool.

Once the project is created you land on the following page:

To start with we will explore the ‘Manage Work’ option first. Below is the screen I got after I clicked ‘Manage Work’ option.

In my next post of this series I will start exploring these links one by one starting with ‘New work item’ section ( at the bottom centre)

Stay tuned!