Python is used often these days in notebooks. As is true in any development environment, there are best practices and good conventions for using Python in notebooks. The following is what I use in my own designs and with my teams.
Tag: Functions
Python Automated NSLOOKUP with socket.gethostbyname()
Sometimes you need to look up a list of hosts to get their IP addresses. Maybe you need to create a quick list for a hosts file, as was my case. This example also includes examples for using a list in python, creating a for loop in python, and a print statement using a custom … Continue reading Python Automated NSLOOKUP with socket.gethostbyname()
SQL Server: Fake a Dynamic IN with STRING_SPLIT
use string_split to actually join your multiple choices to a table! #SQLServer2016 #SQL #TSQL
SQL Server: Duplicate Rows with Your Own Values Using STRING_SPLIT and CROSS JOIN
SQL Server 2016 came out with the STRING_SPLIT function that will return what amounts to a table from character-separated string. Using a CROSS JOIN with this function, you can return one row multiple times with whatever values you want!
SQL Server 2016’s STRING_SPLIT
I found a pretty cool little function as I was perusing the SQL Server functions documentation the other day. (What, doesn't everyone do that?) I just read the name of this function and thought, well, no need to create that function with a loop any longer! Finally, SPLIT has come to SQL Server! What is … Continue reading SQL Server 2016’s STRING_SPLIT
Oracle Single Row Character Functions Returning Character Values
Exam Topic: Using Single-Row Functions to Customize Output - Describe various types of functions available in SQL Single row functions return a result for every row in a result. They can be used in any part of a SQL query, such as the SELECT lists or any part that can use a conditional statement. Oracle 11g has … Continue reading Oracle Single Row Character Functions Returning Character Values
Basic Algebraic Functions
The following is a mini-workout of the basic Algebraic functions found in Oracle 11g. It includes ABS, CEILING, FLOOR, MOD, REMAINDER, NANVL, POWER, ROUND, SIGN, TRUNC and BUCKET_WIDTH. More functions can be found here. ABS (Absolute Value) This function returns the number of positions a number is from zero. select abs(-10) from dual; ABS(-10) ---------- 10 … Continue reading Basic Algebraic Functions
Convert Decimal to Other Number Systems
Just for fun, I made a block of code that will convert decimal numbers to any other number system. Maybe I'll go the other direction next. It's basically a loop. It takes the remainder of the original number divided by the number system (MOD) and adds that to a string. The string is made by … Continue reading Convert Decimal to Other Number Systems
Generate Random Values
One of the best builtin packages in Oracle for anyone who needs to create random data is DBMS_RANDOM. Not only can you use it to create random values, but you can also use it to make random selections. For instance, if you have a list of values that you want to assign randomly, you can weight … Continue reading Generate Random Values
Oracle Single Row Numeric Functions
Exam Topic: Using Single-Row Functions to Customize Output - Describe various types of functions available in SQL Single row functions return a result for every row in a result. They can be used in any part of a SQL query, such as the SELECT lists or any part that can use a conditional statement. Oracle 11g has … Continue reading Oracle Single Row Numeric Functions