I am working in python with sqlite3 and I am trying to create a database. I created a table: c.execute(“CREATE TABLE persoane (nume text, varsta integer, salariu integer)”) Then I added the values into the table: c.execute(“INSERT INTO persoane VALUES(‘David’, 16, 1000)”) When I try to get the values out of the database with fetchall() I get an empty list
Tag: python
Exploding the group by cel in individual cases
I am trying to convert the following table (fictitious): Person year price Tom 2019 100 Klaas 2020 100 John 2019 120 John 2020 120 Klaas 2020 150 Klaas 2020 150 John 2020 150 into: Person year price price price Tom 2019 100 NaN NaN Klaas 2020 100 150 150 John 2019 120 NaN NaN John 2020 120 150 NaN In
SQL Comparison Operator Issue) …right syntax to use near ‘>’2021-06-01’ AND 100*(d1_close-close)/close>’29” at line 1″)
I’m trying to run a SQL query through python file, and I’m getting the error message My query code is as below: I have also tried different versions like below: UPDATE)) I think the syntax error is in the comparison operator. How can I send comparison operator from python to SQL? Answer Triple quotes allow you to write the query
Insert small dictionary like {1:23, 2:45, 3:17} into a column of SQL database table in Postgres using python language
I have a table having one varchar type column and 2 json type columns, which i created using: I now want to insert values like this using python: For which i wrote a string in python like this to execute: But this doesn’t work. I am getting following error: I searched for similar answers but couln’t find one. This should
how to copy values from a column to a non-existent column in postgresql
i have a table like this: and i want to copy the values from the first column to the non existent column that is ‘qty’ how do i do that if they have different data type? what i originally wanted is when the 1st column’s value is 0, then the column qty should be blank or empty, not [null], i
SQLite update data from one table to another
I’m trying to insert some data from one SQLite database to another. I have 2 tables called “members” and “attendance.” What’s supposed to happen is, everytime a new member is added into the member table (or removed), the name and ID of the specific member should also be added to the attendance table. Picture below shows what I’m trying to
How to set up sqlite to be local server (on lan)
Current situation : I have one GUI program(written by python) which using sqlite data stored on my computer. Wishlist: I would like to have one server computer to locate sqlite data (DATA A1) (CRUD operation needed) and ten more client computer using GUI program(written by python) which connect with the sqlite data (DATA A1) on lan. I have no idea
Want to run a query multiple times using a for loop and add each result into a dictionary. This code only execute once even as it loops through
I have a query that take a random sample of records. I want to do this multiple times and add each result into a dictionary, which I will concat into a pandas DataFrame later. This code only execute once even as it loops through. Answer cursor.fetchall() doesn’t execute the query, it just fetches the remaining results from the query that
SQLite Insert Distinct from 2 variables
I have a SQLite DB with a table with the following kind of data: What I need to do is take columns B and C, create a single unduplicated list and autoincrement the primary key for the unique values. It needs to check to make sure an entry is not already existing – so the second table would be: I
while Convert sql query to json getting wrong output
I am getting wrong output Output should be: Answer The problem is with your nested loops. You actually want to parallely iterate both lists. The lists themselves are quite complex due to the nesting of lists and tuples. That’s why you may loose track here. You could try simplifying the lists/objects if possible or storing parts of them in extra