I have written a function by reading an excel file and writing it to the database. This works! Getting data from the database also works. Where I get stuck is at the point that the function should read each row, calculate it and write the result back to the database. I also want to find out how many rows were
Tag: python
Merging pandas DataFrames generated with a loop on SQL Database Data
This works BUT the outputs are not matching on the index (Date). Instead the new columns are added but start at the first dataframes last row i.e. the data is stacked “on top” of each other so the Date index is repeated. Is there a way to iterate and create columns that are matched by Date? Output: Thanks! Answer Just
insert datetime from csv to postgres error
I have a csv file: output: And then I tried to insert the file data into postgres database: Error: It works in psql client. I thought it is the string character ‘T02’ issue,so I use: Then the error became: Then I thought I need convert it to datetime first: Same error as the last one. Then I did some research:
Getting data from Oracle table where two columns equal separate lists
I am pulling data using python, from an ORACLE table. I can pull the rows I need for one of the lists using && the actual list is much longer What I can’t figure out is how to also include another filter from a different list. In this case it is a list of types Any help would be appreciated.
Translate Oracle query into pandas dataframe handling
I have the below dataframe: PARAM1 PARAM2 VALUE A X TUE, WED A Y NO B X MON, WED B Y YES I would like a pythonic way of obtaining the distinct values of param1 that satisfy EITHER of these conditions: Their corresponding param2 = ‘X’ contains the string ‘MON’ Their corresponding param2 = ‘Y’ is equal to ‘YES’. In
How to find the max values of each columns using a single SQL query
I have a table, I want to get all the max values of col1, col2, col3 using one query only. I’m using sqlite and flask-sqlalchemy. I tried but then I got [(88,), (30,), (75,), (93,)] I want the output to be [(93,), (88,), (75,)] How can I do this? Answer I think you want three separate calls to MAX here:
Don’t save info in table
I am trying to save the information to the database in the following way: But I get the following error: Using next data: UPD: Check for data and types, get next UPD2: If I use next code, it’s work: But I want to change table Answer Issue resolved, it works:
Databricks error when change type column from string to numeric
I have a error like: com.databricks.backend.common.rpc.DatabricksExceptions$SQLExecutionException: org.apache.spark.sql.catalyst.parser.ParseException: no viable alternative at input ‘alter table x9concsheet5 Add netto_resultaat'(line 1, pos 29)* when i run this sql command in databricks: %sql alter table x9concsheet5 Add netto_resultaat numeric(17,2) The requirement is to change the column type from string to numeric from the temporary table x9concsheet5. Any suggestions? Answer you can use following command
Updating HTML Table Every 60 Seconds
I am trying to use an ajax call to update an HTML table every 60 seconds on a flask app. I am very new to flask and jquery, and followed this similar stackoverflow question: Python Flask Refresh table every 60 seconds However my table isn’t displaying any data. Currently my app.py file is setup as below: And my nfl_template.html: When
Geopandas to_sql shows geometry column as text in mysql
I am attempting to take multipolygon data from a geojson, read it into a dataframe, and then create a table in mysql containing the data. What’s weird to me is that checking the dtype at the end of the script will show the geometry column correctly as geometry. However, checking the mysql db this column is showing as text. Trying