Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations. Closed 2 years ago. The community reviewed whether to reopen this question 1 year ago and left it
Tag: python
Django filter for all items which contain at least one null value
An answer elsewhere on SO provides the Postgresql NOT(<table> IS NOT NULL) query as an option to find all rows in a table containing one or more null values. How would one apply this query in the Django ORM without writing raw SQL? Or is this a case where raw SQL is required? I couldn’t find an example of such
I am getting a NoneType error when trying to work with Python and Sqlite3
This is a chunk of the code I am using. I am currently making a discord bot, and have several other commands that add to a column. However, on the “classs = …” line, the third line in my code shown above, (extra S is on purpose) I get this error: TypeError: int() argument must be a string, a bytes-like
Insertion by removing ‘000000’ in the unix timestamp
I’m inserting some data for python that comes from a GET in API FLASK like JSON, for some reason when python will insert this data or maybe postgres itself, it is removing the 000000 Data json: Insert py: Original date: Date that python is inserting to pgsql: Conversion correct: Even using the website’s timezone, it returns with a problem select
How to insert into sql query string with a string derived from python list
I have an example SQL query string like this: I need to replace (‘apple’, ‘pear’) with any python list generated. How I can insert any list into the SQL query string without hardcoded in. The code below does not work: It gives a query string ‘select * from myTbl where name in (apple,pear)’ What I need is a query string
How to avoid SQL injection on query
My SQL query construction in python code is: When I run Bandit security tool, it says “Possible SQL injection vector through string-based query construction.” How do I avoid it? Answer Best practices recommend to avoid to dynamically build the query and instead use a parameterized query. But the goal is precisely to avoid what you are doing here: prevent a
How to make separately unique each column in postgresql?
I know we can apply primary key to a column to provide uniqueness for a row and we can apply multiple primary keys and get a composite key. But this didn’t work for my case. I have userID and email columns. And I want them to be unique at the same time. When I applied primary key attribute to both
DatabaseError: ORA-01555: snapshot too old
Data that I wanted to download was about 45,000,000 rows and 38 columns in Oracle 11g database. When I tried to download the data with chunksize=50000 in python, DatabaseError: ORA-01555: …
Django Reverse Regex Match
I have a table (Django Model) and each row/object contains a regular expression that I should evaluate over a given input to filter relevant objects. Is there any Django ORM method to do this? In Postgre it will be: and the opposite of what I am searching for is: I know that evaluating the regular expressions on the application side
Why Django think OR is complex?
I read some model operation from Django’s document, and find this I’m curious that OR in WHERE is just basic concept, why Django think it’s a complex query?