简体   繁体   中英

SQL newbie just trying to import an SQL dump to work with in python, keep getting “missing database” and “missing column” errors

I've been told it's a dump from a MariaDB database. The file looks like this:

-- --------------------------------------------------------
-- Host:                         X
-- Server version:               X
-- Server OS:                    X
-- --------------------------------------------------------

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!50503 SET NAMES utf8mb4 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;

-- Dumping data for table table.mctable: ~42.420 rows (approximately)
/*!40000 ALTER TABLE `mctable` DISABLE KEYS */;
INSERT INTO `mctable` (`created`, `dev`, `no`, `lbl`) VALUES
    ('string', 42, 42, 'string'),
.
.
.
/*!40000 ALTER TABLE `mctable` ENABLE KEYS */;
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;

Is it because this files is missing something? Is there any way I can just import the values into a dataframe or something? I really don't have any need for them to be stored in a database while I work with them.

Shared Dump is missing table schema, If you are importing it to a remote databases you need to create Database and tables schema first.

CREATE DATABASE Billing;    
CREATE TABLE Customer (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
firstname VARCHAR(30) NOT NULL,
lastname VARCHAR(30) NOT NULL
) 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM