Skip to content

Tag: mysql

Python SQL insert statement not working

I am trying to insert Arduino data into a database through Python, however, it will not do it. Basically I am assigning data that I read in from the serial port assigned to my Arduino and storing the first value of it in the variable arduinoData. in my insert statement I am trying to use a string literal to p…

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…

Can I connect to mysql using Psycopg2 lib

I have a project in python that connects to a postgreSQL database. That project have a module that connects to other data base. The connection string is on a configuration file. I configure it to use a mysql database like this: One running the module I always get the following error: line 179, in connect conn…

pandas – Merging on string columns not working (bug?)

I’m trying to do a simple merge between two dataframes. These come from two different SQL tables, where the joining keys are strings: I try to merge them using this: The result of the inner join is empty, which first prompted me that there might not be any entries in the intersection: But when I try to …

How can auto create uuid column with django

I’m using django to create database tables for mysql,and I want it can create a column which type is uuid,I hope it can generate the uuid by itself,that means each time insert a record,I needn’t specify a uuid for the model object.How can I make it,thanks! Answer If you’re using Django >=…

Python MySQL connector – unread result found when using fetchone

I am inserting JSON data into a MySQL database I am parsing the JSON and then inserting it into a MySQL db using the python connector Through trial, I can see the error is associated with this piece of code I have inserted higher level details and am now searching the database to associate this lower level in…

“set session” in a SQLAlchemy session object

I’m using SQLAlchemy for a project, and need to be able to specify a session variable/setting for one specific call for performance reasons: I can of course do this in MySQL directly (on the shell), but how do I set this session variable in a SQLAlchemy session? Answer Use a session event to execute an …