Skip to content
Advertisement

Tag: sql

INSERT table names using SELECT statement in MySQL

In MySQL, I know I can list the tables in a database with: But I want to insert a table name into a specified table, for example: But when I execute the above statement, the dataset_names table does not get updated. I created the master table using: Here is the python code. Answer Here the order on insert values and

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

Convert SQL Query to MongoDB syntax

I have a big problem with converting SQL queries to Mongo DB for Python. I have a question if you know better methods for transferring SQL queries to Mongo DB queries? I have two queries but I still have big problems with the syntax conversion to Mongo DB. Maybe there is someone here who can help me? Table I have

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 how to write an update sql query?

I am trying to write an update query but I could not manage the string. My connections is ok. My query is like this: This is giving me error: undefined column name ‘hello’. I want to update message column as hello but it is getting it as a column name. In sql, when I write it as UPDATE users SET

Advertisement