I am trying to insert rows from a csv file into a MySQL table. I tried this code Nb: tab is a table with two columns name (varchar 20) and nb_cases (double) I get this error: DataError: (1265, “Data truncated for column ‘nb_cases’ at row 1”) Answer your number doesn’t fit it must be 983.469 with a point not a
Tag: sql
How to insert today’s date in SQL select statement using python?
I’m trying to send today variable into SQL but it is not working. Answer You don’t have to compute today’s date in Python. Just use the PostgreSQL function CURRENT_DATE:
BigQuery – Best way to DROP date-sharded tables
I have a few date-sharded tables I want to delete but they already have more than 100 shards for each table and can’t drop them manually. I’ve tried using wildcards but it does not seem to work. I finally used the python API: And it works, but I needed to create the tables array with the names of the tables
execute delete,sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) near “,”,while i
I want to remove duplicate data from the database, This statement can be executed in navicat. error info: sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) near “,”: syntax error [SQL: ‘delete from Proxy_Main where (Proxy_Main.ip,Proxy_Main.port) in (select ip,port from Proxy_Main group by ip,port having count() > 1) and rowid not in (select min(rowid) from Proxy_Main group by ip,port having count()>1)’] (Background on this error at:
Multithreaded pyodbc connection
I am trying to use a pyodbc connection in multiple threads. I am receieving the following error: Connection is busy with results for another command (0) (SQLExecDirectW)’). I also tried setting MultipleActiveResultSets=yes; and got the same results. I really don’t want to have to create a connection for every thread or query. I also don’t want to use a lock
Pandas query function not working with spaces in column names
I have a dataframe with spaces in column names. I am trying to use query method to get the results. It is working fine with ‘c’ column but getting error for ‘a b’ For this I am getting this error: I don’t want to fill up space with other characters like ‘_’ etc. There is one hack using pandasql to
Exporting a PostgreSQL query to a csv file using Python
I need to export some rows from a table in a PostgreSQL database to a .csv file using a Python script: But when I run the script I get this: Does anyone know what can be wrong or give me a tip about? Answer The copy is not an SQL command, it is a command specific for the Postgres terminal
Join pandas dataframes based on column values
I’m quite new to pandas dataframes, and I’m experiencing some troubles joining two tables. The first df has just 3 columns: DF1: And the second has exactly same two columns (and plenty of others): DF2: What I need is to perform an operation which, in SQL, would look as follows: And, as a result, I want to see DF2, complemented
Python – Using pyodbc to connect to remote server using info from Excel data connection
I have an excel (albeit, one that’s on our company server) that has a data connection to our SQL database so we can make nice pivot tables. I would like to get that data into python (on my local computer) so I can do some faster analysis. I have installed pyodbc. Here is the “connection string” from the excel: and
Function sequence error in PYODBC
I am using pyodbc to connect to a database and extract certain data from it. Here is my code: And I got following error after I run above code: pyodbc.Error: (‘HY010’, ‘[HY010] [Microsoft][ODBC SQL Server Driver]Function sequence error (0) (SQLFetch)’) May I know what caused such problem, and how can I fix it? Thanks. Answer I believe your problem is