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
SQL – Selecting rows based on date difference
Suppose we have below table: Code Dt c1 2020-10-01 c1 2020-10-05 c1 2020-10-09 c1 2020-10-10 c1 2020-10-20 c2 2020-10-07 c2 2020-10-09 c2 2020-10-15 c2 2020-10-16 c2 2020-10-20 c2 2020-10-24 Combination of Code and Dt is unique. Rows are sorted based on Code and Dt. Database is Oracle 12. For every code, I want to get list of its Dts that
Logs of executed Query in SQL Server
Database having 5 users All users are running queries on database we need to find what are the things all users doing like (Query , session_id,starttime , endtime,Database name,username , hostname ) we need to insert all the data into one table. Answer
Finding the difference between two rows in SQL and assigning a numerical value to it (SQLite)
I have a table name login_time John 2021-01-02 08:10:52 John 2021-01-02 11:55:01 John 2021-01-04 17:36:22 Amy 2021-01-02 10:12:48 Amy 2021-01-06 11:22:41 Amy 2021-01-06 19:05:07 I want to add a usage_days column. If the same user login within the same day of his last login time, it is considered as the same day. The resulting column should look something like this:
Trigger to update a table whenever there is an insert
I am trying to use a trigger (in SQL Server) to update a table whenever there is an insert on the table but I get an error: Conversion failed when converting date and/or time from character string. Trigger used: The table table_scan is to be updated when there is NULL in start_date after an insert happens. Answer Use IS NULL
how do i rewrite the correct statement for COUNT under this condition
Bring back the count of all the batsmen who have played a certain number of innings only if there are more than one batsman who have played that number of innings. 4 innings – 2 batsmen, 5 innings – 3 batsmen etc. Player is the field name for the batsmens name. I am kinda stuck on how to write the
SQL filter out string that matches condition and with specific exception to pass
Sample data I wanted to filter out all the data that contains test with the exception of one My expected return result is: I can code this in PHP like this. Or in JavaScript like this But I need it in SQL Answer I can see that in your PHP/Js code you’re defining two condition; any value that have ‘test’
Processing mulitple similar rows in Pandas
I have a dataframe pulled from a relational database. A one-to-many join has resulted in many similar rows with one column different. I would like to combine the similar rows but have the differing column data contained within a list, for each unique row. I am also able to change the SQL but I think this may be easier to
Calculate the number of records for each date between 2 dates
I have to create a query to return results for a multi-axis chart. I need to count the number of Ids created for each date between 2 dates. I tried this: DECLARE @StartDate datetime2(7) = ’11/1/…
pymysql.err.ProgrammingError Error while Inserting Row into MySQL table (using Python, Flask, ClearDB)
I have seen numerous posts about this but I have not been able to fix this issue. I am converting my database from SQLite to MySQL and am having an issue when inserting values into a table. In this …