Skip to content
Advertisement

Tag: sql

Error You have an error in your SQL syntax

When I do the following request I get the message : (1064, “You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘>= DATEADD(MONTH, -3, GETDATE())’ at line 1”). The request is : This request works when I remove the WHERE line, however when I

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,

Getting SQL Column to print in Python

I have a code that prints out a specific column from an SQL query table. It prints out fine however I would like it to be put into a file and I cannot think of how to do that. Here is what I have: I was thinking of newfile.write( df[[‘PartNumber’]].to_string() ) however that did not work. Thank you for your

How can I optimze Django Code to only one query request

I have a simple django project which displays previous reservations dates based on id’s. However currently there are 2 requests being made. (N+1 sql requests, where N is the reservation’s count) Do you have any idea how i would be able to optimize this code to only 1 query? This is the model.py file This is the view.py file ->

Python SQL Insert script

I’m creating a Python script to insert some records in a table, but have the following problem: I get the error: “Invalid column name ‘ADIDAS | KID’S STAN SMITH’ How can I fix this with Python? Answer Let’s say this is your tuple:

Assign outcome from SQL query to column

I have a dataframe (test_df) that looks like this: I want to assign the result from executing the query in dq_sql to the column Results. I tried this: which results in: Strange thing is, the ‘X’ result should be assigned to row 1, whereas the query in row 0 does not seem to run. When I try to run the

Advertisement