I recently wrote a python script to extract some data from a JSON file and use it to generate some SQL Insert values for the following statement: The names of some of the attributes are different in my SQL table but the same values are used (example cardClass in the JSON file/Python script is referred to as class_pid in the
Tag: python-3.x
How to get column names from a SQL query?
I need to put data from the SQL query into a Pandas dataframe. Please tell me is it possible to get column names the query results? I found that there is a keys() function in sqlalchemy for that but it does not work for me: AttributeError: ‘CMySQLCursor’ object has no attribute ‘keys’ Answer I think that it your are searching
Overwriting of variable columns in sqlite without string-based construction?
I have a JSON object containing sets of a “keyX” and the corresponding “value”. I need to write the values into a database into the column “keyX”. Unfortunately one can’t format the SQL Query like this: Therefore I’m currently solving it like this: This is working perfectly, but SQL queries shouldn’t be constructed string-based. In this specific case, the keys
Python MariaDB pip install failed, missing mariadb_config
I am using Linux Ubuntu 18.04 and python 3. I am trying to build a connection between a maria-db and my python scripts. Therefore I have to install the mariadb package. I have already installed: sudo …
I am trying to access the data stored in a snowflake table using python sql. Below is the columns given below i want to access
Below is the data-sample and i want to access columns value,start. This data i dumped in one column(DN) of a table (stg) ##consider many lines stored in same column in different rows. Below query only fetched data for name. I want to access other columns value also. This query is a part of python script. Do i need to iterate
Unable to use ‘read_sql’ to call a SQL query class
I am trying to pull results from the database with the following code: I get an error: I saw a similar question at TypeError: ‘pyodbc.Cursor’ object is not callable (Python 3.6) but unable to get an answer from there. Answer I got it to work by editing the class from into
Python3: Can’t write to text file with obtained data from SQL table
I think I am stucked on an easy job as a beginner but have to ask this question. My objective is to create another list from data obtained from a SQL Table. This list will be created in acocrdance …
How do I get Django to run a case-insensitive query against my MySql 5.7 db?
I’m using Django 2.0 and Python 3.7. I have this model and manager for attempting to find my model by a name, case-insentively. The backing database is MySql 5.7. Unfortunately, when the query actually gets created, it doesn’t appear Django is doing anything to account for case-insensitivity. This is an example query that results … What changes do I need
Django ORM filter multiple fields using ‘IN’ statement
So I have the following model in Django: My goal is to have all the tuples grouped by the member with the most recent date. There are many ways to do it, one of them is using a subquery that groups by the member with max date_time and filtering member_loyalty with its results. The working sql for this solution is
Python return error when trying to send a MySQL query that contains MySQL variables
I am trying to retrieve data from a MySQL database by sending a MySQL query using Python. When I send the MySQL Query in MySQL workbench, it runs perfectly fine. When I try the same using Python (in a Jupyter Notebook), it returns an error. Python Code: Error: If I remove the variable in the MySQL Query it runs fine: