All Questions
12,426
questions
0
votes
0
answers
43
views
How to Use a Single INSERT INTO Statement for Multiple Rows in Python?
I’m currently working on a Discord Python bot where I loop through a list of ForumTags and generate an INSERT INTO SQL statement for each object to insert data into a MySQL database.
However, I want ...
0
votes
0
answers
39
views
How to check similarities between two datasets and return a score in Snowflake (is it even possible?)
I have two data sets containing full names of my company customers. Both sets are rather large (40-70k rows). I would like to check if there are similarities between the two groups. For example: if ...
1
vote
2
answers
44
views
SQL command works fine when run manually (SQL Developer) but gives ORA-00922 in Python's oracledb module
I am working with an Oracle SQL database, and I would like to run the command
ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD';
It works fine when I run it from the SQL Developer app manually. ...
1
vote
2
answers
41
views
How to handle invalid cast operations in JSONB column queries in PostgreSQL?
I have a column called tags of type JSONB in my PostgreSQL table called EMPLOYEE.
There is a use case where I want to allow users to query this JSONB column, i.e., tags.
Users can give inputs like:
...
0
votes
2
answers
54
views
SQL not allowing deletion of related data
In SQL I have:
CREATE TABLE Customer(
cust_id INT NOT NULL PRIMARY KEY CHECK (cust_id > 0),
full_name TEXT NOT NULL,
phone TEXT NOT NULL,
...
0
votes
1
answer
54
views
How to write a Case() SQL expression with an aggregated field (Sum) using Django's query builder
I am trying to recreate this SQL statement using Django's query builder:
CASE
WHEN sum(imps) = 0 THEN NULL
ELSE SUM(total_expenses) / (sum(imps) / 1000)
END as "cpm"
I have tried:
...
0
votes
1
answer
46
views
Applying a filter before joining tables
How can I filter joining table results ?
I have 3 tables:
User:
id: str
full_name: str
is_active: bool # NEED TO FILTER BY THIS
tags: Mapped[list["Tag"]] = relationship(
"...
-2
votes
0
answers
29
views
Building database management app, what language? [closed]
I work into administration and as a beginner programmer I wanted to build a database management application. For the choice of the language, What languages do I need? and why? am currently learning ...
0
votes
0
answers
28
views
GraphDB JDBC - from python?
I'm trying to setup a way to execute SQL queries on GraphDB pre-configured JDBC tables. I got it to work using a SQL engine like SQuirrel SQL Client, but so far I have not been successful in Python. I ...
-3
votes
0
answers
45
views
Python: basic example of input sanitization for sql queries
I'm a computer science student and I'm currently learning about writing secure code.
I came across a very simple function to sanitize the input:
import re
def my_sanitize(input_string):
...
0
votes
0
answers
34
views
How to create a wrapper class around a python class which enables chaining?
I tried to create a wrapper class around an object which implements chaining (pypika queries) and realised it's really really awkward to do.
Tried to add a simple .to_df() method to pypika queries, ...
-1
votes
1
answer
57
views
Why does my CREATE TABLE statement return an "incomplete input" error?
The cursor returns an error.
main.py:
def initialize_database():
conn = sqlite3.connect('PostsData.db')
cursor = conn.cursor()
cursor.execute('''
CREATE TABLE IF NOT EXISTS posts (
...
-2
votes
0
answers
39
views
How to determine how much data is sent to the database using SQL and Python
I'm inserting an image file like my.png into a database (table with a column settings of blob) but I want to display the amount of data sent like live update.
Example
import threading
import pymysql
...
0
votes
0
answers
51
views
How to run SQL on Jupyter Notebook/Jupyter Lab? [duplicate]
I am trying to load a database and operate with it with SQL on Jupyter notebooks. I am following the instructions but it doesn't seem to work because it won't run the command %sql:
!pip install ...
0
votes
0
answers
39
views
How to expand * into columns with given query and table with column list
I'm writing a code to expand a SELECT query that uses * or alias.* into SELECT query with defined column names.
The idea is to supply the query, table list and associated column list and return a ...