Take a look at the following code: import ibm_db #Authentication Details f=open(r”C:UsersXXXXXMy Code.rc”,”r”) lines=f.readlines() us=lines[0].rstrip() pd=lines[1] sql_file = “NNM_SQL.sql” f = …
Tag: python
Why does a database query in python not return an integer value?
Why does this work: cash = db.execute(“SELECT cash FROM users WHERE id = :user_id”, user_id = session[“user_id”]) # Ensure user can afford the stock if cash[0][“cash”] < share * quote["price"]…
How to update an integer value in an SQL record?
I’m pretty new to SQL and the Sqlite3 module and I want to edit the timestamps of all the records in my DB randomly. import sqlite3 from time import time import random conn = sqlite3.connect(‘…
Best data type for PostgreSQL datatime type
Actually I have: CREATE TABLE public.user( id BIGSERIAL NOT NULL, nick VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, born DATE, joined DATE, tags text[] ); I want to choose best …
Fast SQL record look-up by using hash in Python/pandas
I’m looking to maintain a (Postgres) SQL database collecting data from third parties. As most data is static, while I get a full dump every day, I want to store only the data that is new. I.e., every …
Do a dry-run of an Alembic upgrade
Sometimes alembic upgrade head may fail at runtime against my production database even though it worked fine against my testing databases. For instance, a migration might add a NOT NULL constraint to a column that didn’t previously contain NULLs in my testing environment, but did contain NULLs in produc…
How to call DBMS_CRYPTO.HASH when inserting a CLOB into Oracle with Python?
I’m storing CLOBs in Oracle. To speed up finding identical CLOBs, I’d like to introduce a hash value of the CLOBs. What I tried so far is INSERT the CLOB UPDATE the hash value based on the stored clob. How can this be done in one operation instead of two? This doesn’t work: (Oracle 12.2 usin…
How do I display attributes of table in oracle using python?
I connected Python to Oracle. I am trying to display the attributes of the table using python i.e I want to display table schema. I am using ‘describe’ statement but while executing it gives me an …
pyodbc Incorrect syntax near ‘-‘. (102)
I am trying to select all data from table that contains “-” dash symbol, and i get error cursor.execute(qStr) pyodbc.ProgrammingError: (‘42000’, “[42000] [Microsoft][ODBC SQL Server Driver][SQL …
There is a way to check if a model field contains a substring?
I wanted to know if I can do things like this: More or less like this. In summary I want to search for a substring, not the string itself. Answer Take a look at Django contains and icontains