Boto Autoscale in other region - boto

I'm trying to use autoscale module from boto. I reach to create an API connexion and get all groups in the default region(us-east-1).
conn = AutoScaleConnection(ACCESS_KEY,SECRET_KEY)
print conn.get_all_groups()
Now I need to create a connexion on the region eu-west-1, but I've always an error.
conn = AutoScaleConnection(ACCESS_KEY,SECRET_KEY)
autoscale = boto.ec2.autoscale.connect_to_region('eu-west-1')
Error:
boto.exception.NoAuthHandlerFound: No handler was ready to authenticate. 1 handlers were checked. ['HmacAuthV4Handler'] Check your credentials
If I try with that:
autoscale = boto.ec2.autoscale.connect_to_region('eu-west-1',ACCESS_KEY,SECRET_KEY)
Error:
TypeError: connect_to_region() takes exactly 1 argument (3 given)

You have to pass additional parameters as keyword parameters, e.g.:
boto.ec2.autoscale.connect_to_region('us-west-2', aws_access_key_id=ACCESS_KEY, aws_secret_access_key=SECRET_KEY)
Alternatively, you could put your credentials in a boto config file (~/.boto) or in environment variables and boto will find them.

Related

fast_executemany=True is not working in flask

I have tried three of them below. But nothing works.
Error: - TypeError: Invalid argument(s) 'fast_executemany' sent to create_engine(), using configuration MSDialect_pyodbc/QueuePool/Engine. Please check that the keyword arguments are appropriate for this combination of components.
engine = create_engine('mysql+pyodbc://{DB}:{Password}#{server}', fast_executemany=True)
engine = create_engine('mysql+mysqlconnector://{DB}:{Password}#{server}', fast_executemany=True)
engine = create_engine('mysql+pymysql://{DB}:{Password}#{server}', fast_executemany=True)

completion of jmeter execution generate the csv file ,how read the csv file in groovy and how to automaticaly pass those values in query ?, ?,? places [duplicate]

Please give step by step process
How to connect MySQL db and excute queries and stored those results in db table by using jsr223 sampler? Please give sample code this topic
Download MySQL JDBC Driver and drop it to "lib" folder of your JMeter installation (or other folder in JMeter Classpath)
Restart JMeter to pick up the .jar
Add Thread Group to your Test Plan
Add JSR223 Sampler to your Thread Group
Put the following code into "Script" area:
import groovy.sql.Sql
def url = 'jdbc:mysql://your-database-host:your-database-port/your-database-name'
def user = 'your-username'
def password = 'your-password'
def driver = 'com.mysql.cj.jdbc.Driver'
def sql = Sql.newInstance(url, user, password, driver)
def query= 'INSERT INTO your-table-name (your-first-column, your-second-column) VALUES (?,?)'
def params = ['your-first-value', 'your-second-value']
sql.executeInsert query, params
sql.close()
Change your-database-host, your-database-port, etc. to real IP address, port, credentials, table name, column name, etc.
Enjoy.
More information:
Apache Groovy - Working with a relational database
Apache Groovy - Why and How You Should Use It
P.S. I believe using JDBC Request sampler would be way faster and easier

How to fix mysql uppercase query in php and mysql

I am currently working on the website that uses ADODB library. In entire website all the queries are written in UPPERCASE.
The problem is when I run the query it doesn't work because of table name which is UPPERCASE. But when I change the table name to lowercase it works.
$sql = "SELECT * FROM MEMBERS where USERNAME = '$username'";
$db = ADONewConnection('mysql');
$db->debug = true;
$db->Connect(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_NAME);
$resultFriends = $db->Execute($sql);
while ($row = $resultFriends->FetchRow()) {
var_dump($row);
die;
}
Here is the error I get:
ADOConnection._Execute(SELECT * FROM MEMBERS where USERNAME = 'fury', false) % line 1012, file: adodb.inc.php
ADOConnection.Execute(SELECT * FROM MEMBERS where USERNAME = 'fury') % line 15, file: index.php
Bear in mind I don't want to change the scripts. There are 1000 files and 10000 places.
Is there any library or are there any way that I can run this queries without error?
The version for live sire was linux kernel. but the new dev site is ubuntu.
I have done this on ubuntu/ mysql CML and it didn't work.
The solution is I had to reconfigure the mySql database in AWS/rdbs
You have to modify the “lower_case_table_names” parameter for your DB Instance(s). Prior to today, the lower_case_table_names parameter was not modifiable, with a system default of zero (0) or “table names stored as specified and comparisons are case sensitive.” Beginning immediately, values of zero and one (table names are stored in lowercase and comparisons are not case sensitive) are allowed. See the MySQL documentation for more information on the lower_case_table_names parameter.
The lower_case_table_names parameter can be specified via the rds-modify-db-parameter-group API. Simply include the parameter name and specify the desired value, such as in the following example:
rds-modify-db-parameter-group example --parameters "name=lower_case_table_names, value=1, method=pending-reboot" --region us-east-1
Support for modifying parameters via the AWS Management Console is expected to be added later this year.
setting the lower_case_table_names parameter via a custom DB Parameter Group and doing so before creating an associated DB Instance. Changing the parameter for existing DB Instances could cause inconsistencies with point-in-time recovery backups and with Read Replicas.
Amazon RDS

DB Security Groups can only be associated with VPC DB Instances using API versions

I have this code below to create a RDS instance in aws:
import boto.rds
REGION="us-east-1"
INSTANCE_TYPE="db.t1.micro"
ID = "MySQL-db-instance-database-test2"
USERNAME="root"
PASSWORD = "pass"
DB_PORT = 3306
DB_SIZE = 5
DB_ENGINE = "MySQL5.1"
DB_NAME = "databasetest2"
SECGROUP_HANDLE="default"
print "Connecting to RDS"
conn = boto.rds.connect_to_region(REGION)
print "Creating a RDS Instance"
instance = conn.create_dbinstance(ID, DB_SIZE, INSTANCE_TYPE, USERNAME, PASSWORD, port=DB_PORT, engine=DB_ENGINE,db_name=DB_NAME, security_groups = [SECGROUP_HANDLE],)
print instance
But I am having always this error related to security groups:
DB Security Groups can only be associated with VPC DB Instances using API versions 2012-01-15 through 2012-09-17.
Can anyone please help solve this issue?
If I use vpc_security_groups instead of security_groups Im having:
<Message>Invalid security group , groupId= f, u, d, t, e, a, l, groupName=.</Message>
RDS instances in VPCs can not be members of RDS security groups. Instead, a RDS within a VPC should be in a VPC security group. In boto, use the vpc_security_groups parameter (with the VPC security group ID as its value) rather the security_groups parameter. See also the boto RDS docs for create_dbinstance().
Boto is migrating RDSConnection from version 1 to version 2. You can check this -
Earlier we could have got all the db_instances using get_all_dbinstances()but now we can only fetch using describe_db_instances().
Try using vpc_security_group().
The official doc for new version of RDS, i.e. RDS2 is here.
this may work. I'm not getting the error with my script but my client is. I'm guessing it's because I have a default VPC security group, which AWS is silently using, and he does not.
boto.rds.RDSConnection.APIVersion = '2012-09-17'
the idea being that, since this API is within (at the end of) the specified range, the error will not apply.
I got the idea from https://github.com/boto/boto/issues/2923

Using SSIS 2012 package parameters for connection properties

I am trying to write ETL that collects data from many identical server into a central repository. What I'm trying to do is write one package with source address, user id and password as parameters and execute the package once per server to be copied.
Is this doable? How can I use parameters to create a source?
I meant to ask how to parametrize the connection manager (is that even a real word?), not where to store the connection parameters. The answer is simple:
Create package parameters for Server, Database, User ID and Password
Create a connection manager as part of defining a data flow component
once a connection is defined, right-click on the connection manager at the bottom of the package design screen and select "Parametrize".
Select "ServerName" in the property drop-down
Select "Use existing parameter" or create new parameter if skipped step 1
If using existing parameter, select it from the drop down
Click OK to save (gotta do it after each parameter)
Repeat steps 4-7 for the rest of the parameters
You can store parameters in a table. Query the table with a sql task and store the results in a object variable. You can then use this variable in a for loop. Use expressions in SSIS to change values of your connection during each loop iteration.
Several books outline this method. Here is a code example.
Here are some steps - hopefully I didn't miss anything. You mention a server "Address", but I'm not sure exactly what you are trying to do. This example queries multiple sql servers.
You create the variables, SQL_RS with type of object, SRV_Conn with type of string. This holds my servername. In the execute SQL task, I have a query which returns the names of sql servers I want to query. Then set the following properties:
SELECT RTRIM(Server) AS servername
FROM ServerList_SSIS
WHERE (Server IS NOT NULL)
and coalesce(exclude,'0') <> 'True'
and IsOracle is Null
Execute SQL Task > General > ResultSet = "Full Result Set"
Execute SQL Task > Result Set Tab "Result Set Name = 0", Variable Name = "User::SQL_RS"
So we have a list of server names in the SQL_RS variable now.
ForEach > Collection > Enumerator = "Foreach ADO Enumerator"
ForEach > Collection > Enumerator Configuration > ADO Object source Variable = User::SQL_RS
This maps the first column of the SQL_RS object to the SRV_Conn variable, so each iteration of the loop will result in a new value in this variable.
ForEach > Variable Mappings > Variable = User::SRV_Conn, Index = 0
Inside the ForEach are some other sql execs, performing queries on sql databases, so I need to change the ServerName of my 'MultiServer' connection. I have another connection for the initial query that got me the list of servers to query. Making the connection dynamic is done in properties of the connection - right-click the connection > properties. Click the ellipses to the right of the expressions.
Connection > Properties > Expressions > Property = ServerName, Expression = "#[User::SRV_Conn]"
Note: The index value of 0 for the variable mapping works for Native OLEDB\SQL Server Native Client. If you're using another db provider, you may need to use other index types - this makes setup more confusing.
OLEDB = 0,1
ADO.NET = #Varname
ADO = #Param1, Param2
ODBC = 1,2
Full listing here.