Skip to content

Tag: python

python function parameter control

I have a function called “getBooks”, and this function is actually a combination of 2 functions. one function must work without taking the ‘name’ parameter, the other must work by taking the ‘name’ parameter because i have to change the sql template according to the ‘name’ parameter. how can i provide that? Answer You can specify a default parameter of

Python – Printing output into a SQL Table

I have a python script that can extract the metadata from pictures in a directory. As of right now they go into a text file in table format and the current output looks like this: Here is the current script I have: The script opens the directory and for each photo it takes the filename, size, type, height, width, DPI,

Pyspark, iteratively get values from column containing json string

I wonder how you would iteratively get the values from a json string in pyspark. I have the following format of my data and would like to create the “value” column: id_1 id_2 json_string value 1 1001 {“1001”:106, “2200”:101} 106 1 2200 {“1001”:106, “2200”:101} 101 Which gives the error Column is not iterable However, just inserting the key manually works,

Any way to pass operators <, , >= into sql-query?

I have such piece of program: What I want to do is write ‘<‘ in command in the same way as {table} and {pkey}, that means I want to pass operators into command from variable. Can I do it? The face of the app looks like this A little bit more of code context. It’s an app, that should get

Python Script to run SQL query UPDATE statement to loop through each row in result set and update columns

Newby working on my first project. Sorry for this explanation. I have 2 x tables: t1: master table with single rows (unique project-id) and 3 status fields, s1,s2,s3 t2: list table with repeating project_id’s with 3 status fields s1,s2,s3 (and other data not relevant here). The value in the s1-3 fields is either true(1) or false(0) table1: project_id, status1, status2,

Pythonic way to optimize SQL VIEW count to extract information schema metadata from Snowflake

I have 12 VIEW tables in Snowflake and I would like to extract TABLE_NAME,CREATED,LAST_ALTERED from Snowflakes INFORMATION Schema for View tables, and also want to get row count for each 12 VIEW tables, along with metadata for Base table mentioned in below code.I was wondering if there is way get row count using below code for 12 VIEW tables or