Python3 MySQL Drivers - mysql

Recently, I switched to Python 3 (3.1 on a FreeBSD system), and i would like to work with MySQL databases.
First i tried to use pymysql3-0.4, but it failed when i used SUM in my query with this error:
, TypeError("Cannot convert b'46691486' to Decimal",))
Then i tried oursql-0.9.2, but it seems it has no unix socket support (the documentation write otherwise but it doesn't recognize the socket protocol.)
Last i decided to give a chance to mypysql-0.5.5 but the installation is failed.
Could you recommend me a properly working MySQL driver for Python 3, or at least solve one of these problems? I would be very greatfull.

The oursql documentation is a little tricky. :$ There is a list of Connection's parameters, but it doesn't contain the unix_socket parameter. If i set that and the the protocol parameter the whole thing is just work fine :)
If someone has trouble with inserting (get _statment charset AttributeError): https://bugs.launchpad.net/oursql/+bug/669184 change the lines in oursql.c with the code in the report, and rebuild it. (it will be fixed in 0.9.3)

Related

DBeaver - missing procedures in MySQL database

I have connected to my work database via DBeaver. Recently colleague told me about a procedure that lets me check newly added entities through our front-end.
And I can't find it in the list of procedures, nor using this query:
SHOW PROCEDURE STATUS WHERE Name LIKE '%name%'
I have the same connection settings as my colleague's, same user, etc, but he uses DbForge and I use DBeaver, cause at some point of time DbForge began having too much restrictions for free version (I wasn't simply able to execute queries), and the older version my colleague gave me didn't install in Windows 11.
So, I'm thinking may be there's some settings in the DBeaver that hide certain stored procedures, or I need to adjust connection settings.
Does anyone has clue on this?
Or may be someone could suggest some alternative to DbForge, which allows to execute queries in the free version and to set colors to connections (I find that thing convenient), and possibly doesn't have this problem, may be because of being more MySQl-oriented.
Thanks in advance!
I've tried to open connection settings and check out the additional parameters there, but can't seem to notice anything relevant.
Ok, seems like there was misunderstanding between me and my colleague, and he actually meant some another DB Server, but with same User/Password combination. Thanks for the comments, that also helped in finding the cause. I really did install MySQL Workbench, saw the same picture in there, and started wondering what else it could be and reading our communication again.
My mistake) The question is no longer actual.

"Configure TableAdapter tbl_users failed. Specified cast is not valid." - Error When Editing/Creating TableAdapter?

Bit of a back story, I was using MySQL Server 5.X on an old server. Retired server and migrated all data to a new server with MySQL 8.0.11 (now 8.0.12) installed. Used Legacy authentication to reduce issues.
This seemed to work and all my programs open/ran as expected. I've been editing them and publishing without any issues as well, however in that time I have not had any reason to change any of the data sources.
I've gone to change the data source today though and can not get it to work for the life of me.
If I try and make any changes I get the error "Configure TableAdapter tbl_users failed. Specified cast is not valid.". Obviously the table name varies and this happens regardless of which table (even trying to add a new table that I've just created).
It seems to work though, but on closer inspection, the delete and update commands are not created which means if I try and run the application I just get errors.
I've currently got:
Visual Studio 2015
MySQL Connector Net 6.9.8
MySQL for Visual Studio 1.2.7
Thanks in advance for any help/ideas.
#A Tyler. I suggest trying to update the MySQL for Visual Studio and MySQL connector to the newest versions. Have you tried that?
I think this issue is somehow related with the one described here.
https://bugs.mysql.com/bug.php?id=31338
This bug dates back to version 5.1 of the connector and VS 2005... should have been fixed right now, but the symptoms are very similar.
Maybe you found any other solution?
Update:
I 'slept' with the problem and found a workaround on the next day. This does not really solve the issue but made it possible to continue with the project.
I went to the 'properties' window of a table adapter and manually edited select and update commands there. It caused the table adapter to reflect these changes and I could use the new table field in my program. For me, this is good enough.

I need some help getting the connection string correct to connect Golang to AWS RDS

I have been looking and looking on how to connect a Golang application to a MySQL database (I am using the MyMySQL library with the database/sql interface). If I use the none native version not the database/sql interface I can get the connection to work perfectly and perform queries. If I try to connect using the database/sql go interface (which I think is the best way to interface to MySQL?) then I just cannot get the connection to work? The error I keep getting is 'Wrong database part of URI'?????
Sorry for the variable names but I have been trying and trying to get various versions working so the names are a bit screwy sorry again.
I am grateful for any help understanding my problem, thanks again for your time.
The mymysql package defines a non-standard URI format for accessing MySQL when using the database/sql package (from their readme):
[PROTOCOL_SPECIFIC*]DBNAME/USER/PASSWD
So in your case you'd want to change your format string to this:
connectionStr := fmt.Sprintf("tcp:%s:3306,%s/%s/%s", database, dbname, user, password)
The reason you are seeing the error you are seeing is that the Open function splits the URI into 3 parts based on / (see this) and fails if it finds less than three parts.
On a side note, unless you have a strong reason for choosing mymysql you should consider using go-sql-driver/mysql as it is an excellent MySQL driver and supports standard MySQL DSNs like you already have defined.

Sequel DB Connection PoolTimeout Error

I have been unable to determine what the cause of the following Sequel::PoolTimeout error is coming from in a Ruby script I have written:
Sequel::PoolTimeout: Sequel::PoolTimeout
hold at /Users/username/.rvm/gems/jruby-1.7.4#all/gems/sequel-4.2.0/lib/sequel/connection_pool/threaded.rb:100
hold at /Users/username/.rvm/gems/jruby-1.7.4#all/gems/sequel-4.2.0/lib/sequel/connection_pool/threaded.rb:93
synchronize at /Users/username/.rvm/gems/jruby-1.7.4#all/gems/sequel-4.2.0/lib/sequel/database/connecting.rb:234
execute at /Users/username/.rvm/gems/jruby-1.7.4#all/gems/sequel-4.2.0/lib/sequel/adapters/jdbc.rb:258
execute at /Users/username/.rvm/gems/jruby-1.7.4#all/gems/sequel-4.2.0/lib/sequel/dataset/actions.rb:793
fetch_rows at /Users/username/.rvm/gems/jruby-1.7.4#all/gems/sequel-4.2.0/lib/sequel/adapters/jdbc.rb:671
each at /Users/username/.rvm/gems/jruby-1.7.4#all/gems/sequel-4.2.0/lib/sequel/dataset/actions.rb:143
single_record at /Users/username/.rvm/gems/jruby-1.7.4#all/gems/sequel-4.2.0/lib/sequel/dataset/actions.rb:583
single_value at /Users/username/.rvm/gems/jruby-1.7.4#all/gems/sequel-4.2.0/lib/sequel/dataset/actions.rb:591
get at /Users/username/.rvm/gems/jruby-1.7.4#all/gems/sequel-4.2.0/lib/sequel/dataset/actions.rb:250
empty? at /Users/username/.rvm/gems/jruby-1.7.4#all/gems/sequel-4.2.0/lib/sequel/dataset/actions.rb:153
scrap at /Users/username/projectname/processers/get_category.rb:46
each at org/jruby/RubyArray.java:1617
each_with_index at org/jruby/RubyEnumerable.java:920
scrap at /Users/username/projectname/processers/get_category.rb:44
scrap at /Users/username/projectname/processers/get_category.rb:32
I have tried this with both MRI and JRuby with exactly the same results.
As per the instructions on the Sequel gem here, I have attempted to raise the pool_timeout limit as follows:
DB = Sequel.connect("jdbc:mysql://localhost/project_db?user=USERNAME&password=PASSWD&max_connections=10&pool_timeout=120")
It seems as though the max_connections and pool_timeout may not be recognized, however I'm not seeing any other way to pass these args on into the connection.
The actual code that is in question here is:
if DB[:products].where(url: url.to_s).empty?
I have seen the code work just fine for a little bit, but without fail it fails either right away or after a couple minutes without any reproducibility in terms of when it occurs. I am starting to suspect that this is a MySQL config issue or something causing the localhost DBMS to have some prolonged delays, although, again, I cannot manually reproduce a visible timeout that I can tell with manual queries, etc.
Any ideas on this issue as to why the timout would keep happening or, more particularly, how to resolve it either via feeding Sequel proper settings (perhaps I have a malformed arg list) or modifying MySQL's /etc/my.cnf for such a scenario?
The Sequel jdbc adapter passes the connection string directly to JDBC, it doesn't parse out embedded options. You need to do:
DB = Sequel.connect("jdbc:mysql://localhost/project_db?user=USERNAME&password=PASSWD", :max_connections=>10, :pool_timeout=>120)

Nodejs + db-mysql Segmentation Fault

I don't know what causes it, but I have a Node app that keeps crashing. The console says Segmentation Fault, and it looks like it happens when two Mysql objects are instantiated (using db-mysql module), which becomes very common when 10+ users are using my site (I don't post the link to the app because I'm afraid the load would crash it ;) if it can be useful I'll post it).
Do you guys have any clue? My packages are up to date. Do you have a better package to use with Mysql (assuming it's where the problem lies)? Do you also encounter Segfault issues using Nodejs (I guess not, bcs stability is one of the main advantges of Node)?
I [think] I was definitely doing something wrong: cerating a new MySQL object and connecting to the DB every time I had a reaquest. Instead, I stored the MySQL object and run a single query for each... query. Working fine so far.