TRUNCATE TRUNCATE is a DDL(Data Manipulation Language) command TRUNCATE is executed using a table lock and whole table is locked for remove all records. We cannot use Where clause with TRUNCATE. TRUNCATE removes all rows from a table. Minimal logging in transaction log, so it is performance wise faster. TRUNCATE TABLE removes the data by deallocating the data pages used to store the table data and records only the page deallocations in the transaction log. Identify column is reset to its seed value if table contains any identity column. To…
Author: phpmypassion
How to connect with redshift in python
Connecting to AWS Redshift with Python The following Python code demonstrates how to establish a connection to an AWS Redshift database using the psycopg2 library. This function sets up a connection and creates a cursor for querying the database. import psycopg2 import psycopg2.extras def redshift_connect(): # Connection and session creation print(“redshift_connect start…”) conn = psycopg2.connect( dbname=”RS_DB_NAME”, host=”HOST_NAME”, port=”RS_PORT”, user=”USER_NAME”, password=”PWD” ) print(“redshift connection variable”, conn) cursor = conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor) return conn, cursor This code defines a redshift_connect function that: Imports the psycopg2 library and its extras module for advanced cursor functionality.…
Set Library Path for python running configuration
******************** Set Library Path for python running configuration ***** -> home/user/.bashrc Add below code in your library path export PATH=”/home/user/anaconda3/bin:$PATH” export PYTHONPATH=”/home/user/anaconda3/bin/md”
How to Convert a Python Dictionary to List
>>> from functools import reduce >>> a = {‘foo’: ‘bar’, ‘baz’: ‘quux’, ‘hello’: ‘world’} >>> list(reduce(lambda x, y: x + y, a.items())) [‘foo’, ‘bar’, ‘baz’, ‘quux’, ‘hello’, ‘world’] explanation: -> a.items() returns a list of tuples. -> Adding two tuples together makes one tuple containing all elements. Thus the reduction creates one tuple containing all keys and values and then the list(…) makes a list from that.
How To Integrate DoubleClick Bid Manager API With Laravel 5.4
In this article I am explaining a simple process to setup Google Bid Manager (DBM) API by PHP Artisan Command with laravel 5.4. You can get campaigns or your line items data either setting up a cron using created command or running command on terminal. First, edit composer.json in the project’s root folder to include the Google Client: { “require”: { “google/apiclient”: “^2.0” } } Next run composer update at shell prompt to pull in the sdk to the vendor folder. php composer.phar install –no-dev Now we would like to…
Process To Test AWS Route53 ChangeResourceRecordSets API from Terminal
image credit: google images Here I am explaining the process to test AWS Route53 ChangeResourceRecordSets API from terminal. you can copy below code and paste that to your terminal then hit an ENTER from your keyboard. aws route53 change-resource-record-sets –hosted-zone-id ZGN2AVYTFOA –change-batch ‘{ “Comment”: “”, “Changes”: [ { “Action”: “CREATE”, “ResourceRecordSet”: { “Name”: “anilc.phpmypassion.com.”, “Type”: “A”, “AliasTarget”: { “HostedZoneId”: “Z26RNL4JYFTOTI”, “DNSName”: “phpmypassion-event-0ddd4472d016751e.elb.us-east-1.amazonaws.com”, “EvaluateTargetHealth”: false } } } ] }’ “HostedZoneId”: Z26RNL4JYFTOTI :- This hosted zone id belongs to Load Balancer Id –hosted-zone-id ZGN2AVYTFOA :- This hosted zone id belongs to…
How to get data from redshift table as dictionary in python
The dict cursors allow to access to the retrieved records using an interface similar to the Python dictionaries instead of the tuples. Add following code into your cursor function cursor_factory=psycopg2.extras.RealDictCursor After adding the above code your cursor should be look like this – cur = con.cursor(cursor_factory=psycopg2.extras.RealDictCursor) if you have an error of not found class .extra – AttributeError: module ‘psycopg2’ has no attribute ‘extras’ Resolved this error by importing class as below import psycopg2 import psycopg2.extras Now if you run this code, you will get data in dictionary from redshift …
Pandas- ImportError: Missing required dependencies [‘numpy’]
This is a common error that sometimes occur when importing pandas library. Here I am sharing the solution for that. So please follow as I described below and if you found any difficulty, intimate me by your comment. Problem:- >>> import pandas Traceback (most recent call last): File “<stdin>”, line 1, in <module> File “/home/anil/anaconda3/lib/python3.6/site-packages/pandas/__init__.py”, line 19, in <module> “Missing required dependencies {0}”.format(missing_dependencies)) ImportError: Missing required dependencies [‘numpy’] Solution:- check all folder list in your python lib folder -> ls -la Now if you see numpy…
Process to Change MySql ip-Address to Listen for all IP’s
*************** process to change MySql ipaddress to listen for all ip ******** -> update user set Host=”%” where User=”phpmyadmin”; -> sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf [change “bind-address = 0.0.0.0”] -> flush privilage -> check by netstat -nlp | grep 3306 [ouput should be start listen on 0.0.0.0] -> telnet 192.168.1.19 3306 [now check its connecting or not with the ip]
Safest Way to Merge A Git Branch Into Master
In this article I am going to explain you about the safest way to merge a git branch(stage branch) into master branch. Git Merge :- ((git merge branch) Never forget to take a pull from your master branch after pushing your all new changes to yourcurrent git branch. If your current branch(stage branch) is up to date and now you want to merge your current branch (stage branch)with master branch then follow below process.Explore phpmypassion for more updates and Follow us on facebook progmypassion/ first checkout to master branch then…
