Common problem faced by developers, how to remove last character from a string using jQuery, Here I am going to explain the solution with an example. var str = ‘123-4’; alert(str.slice(0, -1));
Day: November 26, 2019
Difference between TRUNCATE , DELETE and DROP in MySql Server
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…
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.
