Skip to content

Tag: python

Python Mysql Queary not returning results

I have a DB and when I query a table I get 67 results. The SQL is: I try to connect to the DB, and I get no connection errors. It prints out -1 for rowcount. The connection to the DB appears to be working, the SQL is a simple query… Answer Try adding cursor.fetchall() before the print(cursor.rowcount)

SQL want efficient query to SELECT columnA, columnB FROM table1 WHERE both columnA, columnB are in columnC FROM table2 WHERE columndD > value

I’m searching for a more efficient method to accomplish something that I’ve already solved with a few different SQL statements. The problem: I have two tables a transactions table, and an accounts table The transactions table has columns that look like: acct_sending acct_receiving amount tx_datetime 100 101 10 yyyy-mm-dd hh-mm-ss 101 100 5 yyyy-mm-dd hh-mm-ss 101 200 1 yyyy-mm-dd hh-mm-ss

How can i use value of a combobox in another external file to help cursor.excute to search in database? NameError: name ‘combo1’ is not defined

I’m having trouble using the combobox in an external file. Basically the combobox is in the main file and I would like to use its selected value in the external file. If I select a certain item, it should help cursor.excute to search for a database table, so cursor.execute(“SELECT x FROM Table1 WHERE element = ?”, (combo1,)) As you can

Splitting each Multi-Category columns to Multiple columns with counts

date Value1 Value2 Value3 16-08-2022 a b e 16-08-2022 a b f 16-08-2022 c d f output date Value1_a Value1_c Value2_b Value2_d Value3_e Value3_f 16-08-2022 2 1 2 1 1 2 continues like this for more columns maybe 10, I will aggregate on date and split the categorical columns with counts for each category , currently doing like this Need

How to union two counts queries in SQLAlchemy?

I have two queries and the only difference between then is that one is counting the success status and the other failure status. Is there a way to get this result in just one query? I’m using SQLALchemy to do the queries. Answer You can use conditions on Count, your query will look like: