I'm looking for an information that might look simple to get but i can't put my hands on it.
I wanna create a folder in a SSISDB catalog through a Powershell script, but I get an error saying that Powershell can't load assemblies : Microsoft.sqlserver.BatchParser and Microsoft.sqlserver.BatchParserClient, even though they are present in C:\Windows\Assembly.
But actually I suspect that PowerShell is running with a too old version, which is 2.0. Can anyone confirm that we can can create SSIS catalog folder with a 2.0 Powershell version ?
Thanks for you help
Since no code was provided, it's terribly challenging to debug why it isn't working. However, this code is what I use as part of my ispac deployment.
[Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Management.IntegrationServices") | Out-Null
#this allows the debug messages to be shown
$DebugPreference = "Continue"
# Retrieves a Integration Services CatalogFolder object
# Creates one if not found
Function Get-CatalogFolder
{
param
(
[string] $folderName
, [string] $folderDescription
, [string] $serverName = "localhost\dev2012"
)
$connectionString = [String]::Format("Data Source={0};Initial Catalog=msdb;Integrated Security=SSPI;", $serverName)
$connection = New-Object System.Data.SqlClient.SqlConnection($connectionString)
$integrationServices = New-Object Microsoft.SqlServer.Management.IntegrationServices.IntegrationServices($connection)
# The one, the only SSISDB catalog
$catalog = $integrationServices.Catalogs["SSISDB"]
$catalogFolder = $catalog.Folders[$folderName]
if (-not $catalogFolder)
{
Write-Debug([System.string]::Format("Creating folder {0}", $folderName))
$catalogFolder = New-Object Microsoft.SqlServer.Management.IntegrationServices.CatalogFolder($catalog, $folderName, $folderDescription)
$catalogFolder.Create()
}
else
{
$catalogFolder.Description = $folderDescription
$catalogFolder.Alter()
Write-Debug([System.string]::Format("Existing folder {0}", $folderName))
}
return $catalogFolder
}
$folderName = "ProdSupport HR export"
$folderDescription = "Prod deployment check"
$serverName = "localhost\dev2012"
$catalogFolder = Get-CatalogFolder $folderName $folderDescription $serverName
There may be more graceful ways of doing this within PowerShell but this gets the job done. Logically reading the above code
Create a SqlClient connection to the server in question
Instantiate the IntegrationServices class
Point it at the actual catalog (assumes it has already been created)
Test whether the folder already exists
If the folder does not exist, create it
If the folder exists, update the description
Related
I am new to python boto3. As per my requirement I need to move lambda function from one region to another region.
Any one could you please help to provide the code snippet on the requirement. I have searched earlier posts in the stackoverflow but it I did not get the correct one
Thanks in advance.
I have tried using lambda_client.get_function and create function but its not worked.
The answer is quite a bit more complicated than just copying the function from one region to another, but it is possible. Here's some example code that can help get you started.
import boto3
profile = "my-aws-profile"
function_name = "hello_world"
# Setup the source region client
kwargs_east = {
"profile_name": profile,
"region_name": "us-east-1"
}
session_east = boto3.Session(**kwargs_east)
client_east = session_east.client("lambda")
# Setup the destination region client
kwargs_west = {
"profile_name": profile,
"region_name": "us-west-2"
}
session_west = boto3.Session(**kwargs_west)
client_west = session_west.client("lambda")
# Get the details of the source lambda function
response = client_east.get_function(
FunctionName=function_name
)
# Save the source configuration
lambda_config = response["Configuration"]
# Define Code Location - You'll need to copy the lambda code to a bucket in the destination region
s3_bucket = "my-example-us-west-2"
s3_key = "lambda.py.zip"
# Use the source config and code location to deploy the new function
response = client_west.create_function(
FunctionName=lambda_config["FunctionName"],
Runtime=lambda_config["Runtime"],
Role=lambda_config["Role"],
Handler=lambda_config["Handler"],
Code={
'S3Bucket': s3_bucket,
'S3Key': s3_key
},
Description=lambda_config["Description"],
Timeout=int(lambda_config["Timeout"]), # Note you have to cast the string to an int
MemorySize=int(lambda_config["MemorySize"]) # Note you have to cast the string to an int
)
i have the following code which has been getting me data from flat files. but now all of a sudden i am getting this error
System.Data.OleDb.OleDbException: Invalid path or file name
but the code hasnt changed it worked for months,im not sure what went wrong.
System.Web.Script.Serialization.JavaScriptSerializer json = new System.Web.Script.Serialization.JavaScriptSerializer();
string jsonText;
System.Collections.Generic.List<object> objList = new List<object>();
string strConn = #"Provider=vfpoledb;Data Source=\\10.0.0.0\wwwroot\apps\assembly\FlatDatabaseDbfs\vt_Flat.dbf;Collating Sequence=machine;";
using (System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(strConn))
{
System.Data.OleDb.OleDbCommand cmddbf = new System.Data.OleDb.OleDbCommand();
cmddbf.Connection = conn;
conn.Open();
cmddbf.CommandText = "select * from vt_Flat";
var dr = cmddbf.ExecuteReader();
while (dr.Read())
{
objList.Add(new
{
Code = (dr["dp_code"].ToString().Trim()),
});
};
}
var filteredList = objList.Where(obj => ((dynamic)obj).Status == (Request.QueryString["Status"] ?? "") && ((dynamic)obj).DepCode == (Request.QueryString["Code"] ?? ""));
jsonText = json.Serialize(filteredList);
Response.Write(jsonText);
}
is there something wrong with iis permissions?
Aside from the connection having to point to the PATH as already noted by Oleg, in the C# instances of OleDbConnection I have done in the past, the connection string uses
Provider=VFPOLEDB.1
Don't know if it is case/sensitive issue and the ".1" which is also part of the provider string.
Once you have a valid connection to the PATH, then your query can query from any table within the path location. So if you had 2+ files, and needed to join them, you would do so with a standard query / join. In your case, your command text is only "select *" since you changed your original connection that included the table. Change the command text to
"select * from vt_Flat"
OTHER CONSIDERATIONS
Is this being run from some web service project? If so, THAT could be the basis. You as a developer testing are running with your permissions / access. If running as a web server, the WEB-based user account may not have permissions to the folder to process / work with the data.
Check the folder of your production data to ALLOW the web user if so running. If that doesn't work, set permissions on the folder to EVERYBODY (only for testing/confirmation purposes only). See if that is the problem.
Also, from the Provider connection, did you try with it as all upper case VFPOLEDB.1?
Use path instead of file name, e.g.:
Data Source=\\10.0.0.0\wwwroot\apps\assembly\FlatDatabaseDbfs\;
I'm new to Gradle and Groovy and I'm trying to define a task that executes a SQL script in MySQL. Here's what I have so far:
task executeSomeSQL(type: Exec){
def pwd = getMySQLPwd()
workingDir './'
commandLine 'mysql', '-uroot', "--password=$pwd", 'dbname'
standardInput file('database/script.sql').newInputStream()
}
Now this works as expected, however, I'd like to be able to define many such tasks that only differ in the input script that they take. In my mind, I need a way to prototype the SQL execution task with common properties (getting the password, setting the working directory and setting the command) and then define each task with its own filename. In a sort of pseudocode:
// define a function or closure? this doesn't work because the
// three task specific properties aren't defined
def sqlExecutorDef(filename){
def pwd = getMySQLPwd()
workingDir './'
commandLine 'mysql', '-uroot', "--password=$pwd", 'dbname'
standardInput file(filename).newInputStream()
}
// this is truly pseudocode: somehow the task should be created
// using a function that defines it
task executeSomeSQL(type: Exec) = sqlExecutorDef('database/script.sql')
In this way, I could define many tasks, one per SQL script that needs to be executed, with a one-liner.
EDIT: this is probably trivial for somebody with more Groovy experience. I apologize!
Though this may not be standard Gradle, dynamic tasks might help out here. The example below uses a list both as task names and (with some massaging) sql files: (it simply prints to the console, but executing the SQL should be straight-forward given your original work):
def username = "admin"
def password = "swordfish"
def taskNames = ["abc_sql", "def_sql", "ijk_sql"]
taskNames.each { taskName ->
def sqlFile = taskName.replaceAll("_", ".")
task "${taskName}" (type:Exec) {
workingDir "."
commandLine "echo", "run SQL script '${sqlFile}' as ${username} / ${password}"
}
}
gradle tasks gives:
[snip]
Other tasks
-----------
abc_sql
def_sql
ijk_sql
example run of 'abc_sql':
bash-3.2$ gradle abc_sql
:abc_sql
run SQL script 'abc.sql' as admin / swordfish
I am trying to execute a SSIS 2012 package programmatically using PowerShell, and I need to use PackageInfo.ExecutionValueParameterSet class to set the values for package and project parameters at run-time. Does anyone know how to do this in PowerShell? I found the following post showing how to do that in C# but can't find any way to achieve this in PowerShelll.
ssisPackage.Execute (false, null, executionParameter) times out
Here is the PowerShell code that worked for me:
$setValueParameters = New-Object 'System.Collections.ObjectModel.Collection[Microsoft.SqlServer.Management.IntegrationServices.PackageInfo+ExecutionValueParameterSet]';
$executionParameter = New-Object 'Microsoft.SqlServer.Management.IntegrationServices.PackageInfo+ExecutionValueParameterSet';
$executionParameter.ObjectType = 50;
$executionParameter.ParameterName = "SYNCHRONIZED";
$executionParameter.ParameterValue = 1;
$setValueParameters.Add($executionParameter);
$executionIdentifier = $ssisPackage.Execute("true", $null, $setValueParameters);
You can configure the rest of the SSIS package by following the instructions in this link: http://www.databasejournal.com/features/mssql/ssis-2012-using-powershell-to-configure-package-execution-parameters.html
I am new to Batch scripting. I am wondering whether can batch scripting allows to import excel sheets into mysql?
If it is possible, can someone provide me some help?
You can read Excel files via Oledb or Excel COM interface.
Take a look at this Scripting Guys' article. A brief copy-and-paste for the Oledb alternative:
$strFileName = "C:\Data\scriptingGuys\Servers.xls"
$strSheetName = 'ServerList$'
$strProvider = "Provider=Microsoft.Jet.OLEDB.4.0"
$strDataSource = "Data Source = $strFileName"
$strExtend = "Extended Properties=Excel 8.0"
$strQuery = "Select * from [$strSheetName]"
$objConn = New-Object System.Data.OleDb.OleDbConnection("$strProvider;$strDataSource;$strExtend")
$sqlCommand = New-Object System.Data.OleDb.OleDbCommand($strQuery)
$sqlCommand.Connection = $objConn
$objConn.open()
$DataReader = $sqlCommand.ExecuteReader()
While($DataReader.read()) {
# Insert data into MySql here
}
$dataReader.close()
$objConn.close()
Powershell can connect into MySql quite easily via .Net, if you have installed Mysql.Net connector.