There is a scenario where I want to go through and remove all databases that have specific text in the database name. It always drops one database and then does nothing. How can I fix this? def …
Tag: python
Is there other option to check if a table is in a SQl connection , Im trying to use dialect.has_table
Im getting this error : AttributeError: ‘Engine’ object has no attribute ‘exec_driver_sql’ Answer Nowadays the preferred method for performing such reflection is to use inspect:
Count number of weeks, days and months from a certain date in PySpark
So, I have a DataFrame of this type: And I want to create multiple columns containing, for each line, the current day, week, month and year from a certain date(simply a year, like 2020 for 2020-01-01). At first I thought of using something like this line of code unfortunately this wouldn’t work (except for year and month) correctly since my
How to fix the error: ValueError: endog and exog matrices are different sizes
I’m trying to write a program in python that uses a query in SQL to collect data and make a regression model. When I try to actually create the model, however, it gives me this error. I’m pretty sure that I know what is going wrong, but I have no idea how to fix it. I’ve tried several things already,
Update SQL database registers based on JSON
I have a table with 30k clients, with the ClientID as primary key. I’m getting data from API calls and inserting them into the table using python. I’d like to find a way to insert rows with new clients and, if the ClientID that comes with the API call already exists in the table, update the existing register with the
Conditional annotations with Aggregation over only some fields in Django
So lets assume i have two databases in my Django project There exist multiple Price entries per day for the same article. Now I want to annotate an article queryset with the average price of every article on the previous day. But I have no idea on how to do this in one efficient query. What I have done is
Custom Week Number SQL
I need to convert the following logic to python and SQL (SQL query is more imp): I have a table with ID and Date columns. I need to add a column called “Week_Num” such that: Every time it sees a new ID, Week_Num becomes 1 7 dates correspond to 1 week so if the first week begins on 29th Oct
Django – complicated ORM Query (related_set)
I have model Car, Listing and Website. I want to filter all car objects that have listing object on the given website but the listing needs to be active. To get all car objects that have listing object on the given website: But how do I filter out inactive listings? I want something like: Answer You would do an extra
How create Postgres database using SQLAlchemy
I want write project using database library (SQLAlchemy). When I use SQLite, all works good, but when I deploy project on server (Heroku with Postgres plugin), It doesn’t work. This is code for my database: I have engine & Base variable: In DATABASE_URL link to base on Heroku(Postgres). For create database I write in Interactive Python Console: After these manipulations
Django QuerySet annotate with Subquery
given the following model I’m trying to get, my Pizza and the number of toppings, along with the top 3 other pizzas (top in terms of the number of toppings) The final result should be: a list containing the current pizza, and the top 3 pizzas, along with the count of toppings for all. So right now I have a