There is a file - b15.local.sql. How to connect to the database and with the help of which libraries do this? It is possible with an example, since

import MySQLdb db = MySQLdb.connect(host="localhost", # your host, usually localhost user="root", # your username passwd="31415", # your password db="b15") 

gives an error that the database does not exist, with db = 'b15.local' and db = 'b15.local.sql' give the same error

  • Clarify the question. What exactly do you want to do? You can connect to MySQL in different ways using different modules ... - MaxU
  • I want to connect to the database using the MySQL library for further work with the data, but examples from the network like import MySQLdb db = MySQLdb.connect (host = "localhost", #your host, usually localhost user = "root", #your username passwd = "31415", # your password db = "b15") They give errors and I need a good example of how to connect and get data - Stepan Molostov
  • one
    There is a file - b15.local.sql. Most likely, this is a backup - a script to recreate the database, and not the database itself. It must be deployed (run) on an existing MySQL server. After that, you can connect to the created and filled database - if the recovery fails. - Akina
  • "I agree with the previous speaker," look at what's in your file, if it's just SQL text instructions, then this is really a backup (unload) from the database. - Alex Titov

1 answer 1

You have already been answered. In order to work with the database, you need to install a MySQL server where and deploy the dump https://habrahabr.ru/post/105954/ if you want to work with the database exactly as with a file, this https: // github converter may be useful . com / dumblob / mysql2sqlite and sqlite3 module