Trying to transfer some code from an Rpi to Beaglebone black. This code uses mysql to store and retrieve temporal data, and to keep history. In order to get a working database on the black, I had to load both Mysql and Maria db in order to get a working system. Research on the internet does not give any definitive install instructions for either database. Having a working data base, I then tried to access it from a python program, using pysql installed with pip. Trying to connect to the database I get:
Traceback (most recent call last):
File “/var/lib/cloud9/python/dbtest.py”, line 37, in
Run_first()
File “/var/lib/cloud9/python/dbtest.py”, line 6, in Run_first
db = pymysql.connect(‘localhost’,‘Remote1’,‘’,‘Battery1’)
TypeError: init() takes 1 positional argument but 5 were given
If one checks the .connect structure in the pysql module using the help() function, it takes many more than 5 variables, most of which are optional.
Program code:
Load from datbse on power up
db = pymysql.connect('localhost','Remote1','','Battery1')
csr1 = db.cursor()
sql = """SELECT * FROM tempdat WHERE x_key = 1 ;"""
try:
rsql=csr1.execute(sql)
rsql_dt = csr1.fetchall()
print(1094,rsql_dt[0])
except Exception as e:
print("first",e)
db.close()
return()
using python running in terminal window, it was discovered that the added variable was ‘debian’@‘localhost’ as user, which mysql was not configured to accept.
Has anyone got this working?
I don’t particularly want to change all the code for sqlite3, as the changes are significant.
debian@beaglebone:/var/lib/cloud9$ mysql --version
mysql Ver 15.1 Distrib 10.3.36-MariaDB, for debian-linux-gnueabihf (armv7l) using readline 5.2