R
R
Re7r02022-04-11 09:02:59
MySQL
Re7r0, 2022-04-11 09:02:59

How to work with ready sql database?

How to work with ready sql database? I have a sql file and how do I connect it so that I can work with it through python.

spoiler
-- phpMyAdmin SQL Dump
-- version 4.9.5deb2
-- https://www.phpmyadmin.net/
--
-- Хост: localhost
-- Час створення: Квт 09 2022 р., 14:22
-- Версія сервера: 8.0.28-0ubuntu0.20.04.3
-- Версія PHP: 7.4.3

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @[email protected]@CHARACTER_SET_CLIENT */;
/*!40101 SET @[email protected]@CHARACTER_SET_RESULTS */;
/*!40101 SET @[email protected]@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- База даних: `history_futures_binance`
--

-- --------------------------------------------------------

--
-- Структура таблиці `0_config`
--

CREATE TABLE `0_config` (
  `symbol` varchar(20) NOT NULL,
  `tick_status` tinyint(1) NOT NULL,
  `percent_level` decimal(30,1) NOT NULL,
  `last_tick_time` int NOT NULL,
  `stream_1` int NOT NULL DEFAULT '1',
  `stream_2` int NOT NULL DEFAULT '2',
  `trading_status` enum('on','off','off_now_close','off_after_close') NOT NULL,
  `trading_state` json NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Дамп даних таблиці `0_config`
--

INSERT INTO `0_config` (`symbol`, `tick_status`, `percent_level`, `last_tick_time`, `stream_1`, `stream_2`, `trading_status`, `trading_state`) VALUES
('1INCH', 1, '3.0', 1648827226, 1, 2, 'on', 'null'),
('1000SHIB', 1, '3.0', 1648815685, 1, 2, 'on', 'null'),
('1000XEC', 1, '3.0', 1648828792, 1, 2, 'on', 'null'),
('AAVE', 1, '3.0', 1648828129, 1, 2, 'on', 'null'),
('ADA', 1, '3.0', 1648824847, 1, 2, 'on', 'null'),
('AKRO', 1, '3.0', 1648828639, 1, 2, 'on', 'null'),
('ALGO', 1, '3.0', 1648815845, 1, 2, 'on', 'null'),
('ALICE', 1, '3.0', 1648829118, 1, 2, 'on', 'null'),
('ALPHA', 1, '3.0', 1648829019, 1, 2, 'on', 'null'),
('ANC', 1, '3.0', 1648829220, 1, 2, 'on', 'null'),
('ANKR', 1, '3.0', 1648815868, 1, 2, 'on', 'null'),
('ANT', 1, '3.0', 1648818503, 1, 2, 'on', 'null'),
('APE', 1, '3.0', 1648823344, 1, 2, 'on', 'null'),
('API3', 1, '3.0', 1648828582, 1, 2, 'on', 'null'),
('ARPA', 1, '3.0', 1648827903, 1, 2, 'on', 'null'),
('AR', 1, '3.0', 1648814162, 1, 2, 'on', 'null'),
('ATA', 1, '3.0', 1648818494, 1, 2, 'on', 'null'),
('ATOM', 1, '3.0', 1648825539, 1, 2, 'on', 'null'),
('AUDIO', 1, '3.0', 1648814552, 1, 2, 'on', 'null'),
('AVAX', 1, '3.0', 1648814562, 1, 2, 'on', 'null'),
('AXS', 1, '3.0', 1648813059, 1, 2, 'on', 'null'),
('BAKE', 1, '3.0', 1648829037, 1, 2, 'on', 'null'),
('BAL', 1, '3.0', 1648810656, 1, 2, 'on', 'null'),
('BAND', 1, '3.0', 1648824460, 1, 2, 'on', 'null'),
('BAT', 1, '3.0', 1648818575, 1, 2, 'on', 'null'),
('BCH', 1, '3.0', 1648813736, 1, 2, 'on', 'null'),
('BEL', 1, '3.0', 1648825509, 1, 2, 'on', 'null'),
('BLZ', 1, '3.0', 1648825604, 1, 2, 'on', 'null'),
('BNB', 1, '3.0', 1648828022, 1, 2, 'on', 'null'),
('BNX', 1, '3.0', 1648825604, 1, 2, 'on', 'null'),
('BTS', 1, '3.0', 1648814596, 1, 2, 'on', 'null'),
('C98', 1, '3.0', 1648827326, 1, 2, 'on', 'null'),
('CELO', 1, '3.0', 1648813739, 1, 2, 'on', 'null'),
('CELR', 1, '3.0', 1648824975, 1, 2, 'on', 'null'),
('CHR', 1, '3.0', 1648814437, 1, 2, 'on', 'null'),
('CHZ', 1, '3.0', 1648815785, 1, 2, 'on', 'null'),
('COMP', 1, '3.0', 1648825525, 1, 2, 'on', 'null'),
('COTI', 1, '3.0', 1648815852, 1, 2, 'on', 'null'),
('CRV', 1, '3.0', 1648814434, 1, 2, 'on', 'null'),
('CTK', 1, '3.0', 1648827118, 1, 2, 'on', 'null'),
('CTSI', 1, '3.0', 1648814543, 1, 2, 'on', 'null'),
('CVC', 1, '3.0', 1648824629, 1, 2, 'on', 'null'),
('DASH', 1, '3.0', 1648815671, 1, 2, 'on', 'null'),
('DEFI', 1, '3.0', 1648829217, 1, 2, 'on', 'null'),
('DENT', 1, '3.0', 1648829217, 1, 2, 'on', 'null'),
('DGB', 1, '3.0', 1648828332, 1, 2, 'on', 'null'),
('DODO', 1, '3.0', 1648825111, 1, 2, 'on', 'null'),
('DOGE', 1, '3.0', 1648822541, 1, 2, 'on', 'null'),
('DOT', 1, '3.0', 1648814437, 1, 2, 'on', 'null'),
('DUSK', 1, '3.0', 1648827909, 1, 2, 'on', 'null'),
('DYDX', 1, '3.0', 1648818520, 1, 2, 'on', 'null'),
('EGLD', 1, '3.0', 1648811144, 1, 2, 'on', 'null'),
('ENJ', 1, '3.0', 1648829164, 1, 2, 'on', 'null'),
('ENS', 1, '3.0', 1648828005, 1, 2, 'on', 'null'),
('EOS', 1, '3.0', 1648827910, 1, 2, 'on', 'null'),
('ETC', 1, '3.0', 1648825084, 1, 2, 'on', 'null'),
('FIL', 1, '3.0', 1648818679, 1, 2, 'on', 'null'),
('FLM', 1, '3.0', 1648825518, 1, 2, 'on', 'null'),
('FLOW', 1, '3.0', 1648828340, 1, 2, 'on', 'null'),
('FTM', 1, '3.0', 1648826168, 1, 2, 'on', 'null'),
('GALA', 1, '3.0', 1648814595, 1, 2, 'on', 'null'),
('GMT', 1, '3.0', 1648826332, 1, 2, 'on', 'null'),
('GRT', 1, '3.0', 1648814516, 1, 2, 'on', 'null'),
('GTC', 1, '3.0', 1648825469, 1, 2, 'on', 'null'),
('HBAR', 1, '3.0', 1648744148, 1, 2, 'on', 'null'),
('HNT', 1, '3.0', 1648825526, 1, 2, 'on', 'null'),
('HOT', 1, '3.0', 1648827966, 1, 2, 'on', 'null'),
('ICP', 1, '3.0', 1648814528, 1, 2, 'on', 'null'),
('ICX', 1, '3.0', 1648822332, 1, 2, 'on', 'null'),
('IMX', 1, '3.0', 1648819095, 1, 2, 'on', 'null'),
('IOST', 1, '3.0', 1648829218, 1, 2, 'on', 'null'),
('IOTA', 1, '3.0', 1648744224, 1, 2, 'on', 'null'),
('IOTX', 1, '3.0', 1648814159, 1, 2, 'on', 'null'),
('KAVA', 1, '3.0', 1648818504, 1, 2, 'on', 'null'),
('KLAY', 1, '3.0', 1648822148, 1, 2, 'on', 'null'),
('KNC', 1, '3.0', 1648744266, 1, 2, 'on', 'null'),
('KSM', 1, '3.0', 1648759048, 1, 2, 'on', 'null'),
('LINA', 1, '3.0', 1648829221, 1, 2, 'on', 'null'),
('LINK', 1, '3.0', 1648814555, 1, 2, 'on', 'null'),
('LIT', 1, '3.0', 1648827327, 1, 2, 'on', 'null'),
('LPT', 1, '3.0', 1648744262, 1, 2, 'on', 'null'),
('LRC', 1, '3.0', 1648825457, 1, 2, 'on', 'null'),
('LTC', 1, '3.0', 1648735257, 1, 2, 'on', 'null'),
('LUNA', 1, '3.0', 1648827935, 1, 2, 'on', 'null'),
('MANA', 1, '3.0', 1648810941, 1, 2, 'on', 'null'),
('MASK', 1, '3.0', 1648762143, 1, 2, 'on', 'null'),
('MATIC', 1, '3.0', 1648735480, 1, 2, 'on', 'null'),
('MKR', 1, '3.0', 1648826780, 1, 2, 'on', 'null'),
('MTL', 1, '3.0', 1648814448, 1, 2, 'on', 'null'),
('NEAR', 1, '3.0', 1648828265, 1, 2, 'on', 'null'),
('NEO', 1, '3.0', 1648817393, 1, 2, 'on', 'null'),
('NKN', 1, '3.0', 1648824467, 1, 2, 'on', 'null'),
('OCEAN', 1, '3.0', 1648742853, 1, 2, 'on', 'null'),
('OGN', 1, '3.0', 1648742849, 1, 2, 'on', 'null'),
('OMG', 1, '3.0', 1648828263, 1, 2, 'on', 'null'),
('ONE', 1, '3.0', 1648824468, 1, 2, 'on', 'null'),
('ONT', 1, '3.0', 1648814543, 1, 2, 'on', 'null'),
('PEOPLE', 1, '3.0', 1648828634, 1, 2, 'on', 'null'),
('QTUM', 1, '3.0', 1648828947, 1, 2, 'on', 'null'),
('RAY', 1, '3.0', 1648828168, 1, 2, 'on', 'null'),
('REEF', 1, '3.0', 1648815843, 1, 2, 'on', 'null'),
('REN', 1, '3.0', 1648827077, 1, 2, 'on', 'null'),
('RLC', 1, '3.0', 1648825467, 1, 2, 'on', 'null'),
('ROSE', 1, '3.0', 1648814555, 1, 2, 'on', 'null'),
('RSR', 1, '3.0', 1648827909, 1, 2, 'on', 'null'),
('RUNE', 1, '3.0', 1648818687, 1, 2, 'on', 'null'),
('RVN', 1, '3.0', 1648825470, 1, 2, 'on', 'null'),
('SAND', 1, '3.0', 1648813680, 1, 2, 'on', 'null'),
('SC', 1, '3.0', 1648827998, 1, 2, 'on', 'null'),
('SFP', 1, '3.0', 1648828127, 1, 2, 'on', 'null'),
('SKL', 1, '3.0', 1648828110, 1, 2, 'on', 'null'),
('SNX', 1, '3.0', 1648828869, 1, 2, 'on', 'null'),
('SOL', 1, '3.0', 1648814472, 1, 2, 'on', 'null'),
('SRM', 1, '3.0', 1648814141, 1, 2, 'on', 'null'),
('STMX', 1, '3.0', 1648815854, 1, 2, 'on', 'null'),
('STORJ', 1, '3.0', 1648814595, 1, 2, 'on', 'null'),
('SUSHI', 1, '3.0', 1648815919, 1, 2, 'on', 'null'),
('SXP', 1, '3.0', 1648821174, 1, 2, 'on', 'null'),
('THETA', 1, '3.0', 1648828238, 1, 2, 'on', 'null'),
('TLM', 1, '3.0', 1648744154, 1, 2, 'on', 'null'),
('TOMO', 1, '3.0', 1648826035, 1, 2, 'on', 'null'),
('TRB', 1, '3.0', 1648818521, 1, 2, 'on', 'null'),
('TRX', 1, '3.0', 1648735273, 1, 2, 'on', 'null'),
('UNFI', 1, '3.0', 1648824515, 1, 2, 'on', 'null'),
('UNI', 1, '3.0', 1648818185, 1, 2, 'on', 'null'),
('VET', 1, '3.0', 1648815857, 1, 2, 'on', 'null'),
('WAVES', 1, '3.0', 1648827004, 1, 2, 'on', 'null'),
('XEM', 1, '3.0', 1648829096, 1, 2, 'on', 'null'),
('XLM', 1, '3.0', 1648828127, 1, 2, 'on', 'null'),
('XMR', 1, '3.0', 1648811139, 1, 2, 'on', 'null'),
('XRP', 1, '3.0', 1648815854, 1, 2, 'on', 'null'),
('XTZ', 1, '3.0', 1648825519, 1, 2, 'on', 'null'),
('YFI', 1, '3.0', 1648825515, 1, 2, 'on', 'null'),
('ZEC', 1, '3.0', 1648742571, 1, 2, 'on', 'null'),
('ZEN', 1, '3.0', 1648824862, 1, 2, 'on', 'null'),
('ZIL', 1, '3.0', 1648828585, 1, 2, 'on', 'null'),
('ZRX', 1, '3.0', 1648819324, 1, 2, 'on', 'null');
COMMIT;

/*!40101 SET [email protected]_CHARACTER_SET_CLIENT */;
/*!40101 SET [email protected]_CHARACTER_SET_RESULTS */;
/*!40101 SET [email protected]_COLLATION_CONNECTION */;

Answer the question

In order to leave comments, you need to log in

4 answer(s)
V
Vladimir Korotenko, 2022-04-11
@firedragon

install SQl management studio, create a database, run the
6253c603ec64f096698588.png
script

A
Akina, 2022-04-11
@Akina

This is not a database. This is a dump - a portable copy of the structure and data that allows you to recreate the database.
The dump comments indicate that the dump source was MySQL server version 8.0.28. Therefore, you should restore on the MySQL server, and it is highly desirable on a version not lower than 8.0.4. When restoring to a lower version or partially compatible MariaDB, there may be problems during recovery that will require manual adjustment of the dump - and this requires certain knowledge, which most likely is not.
To restore on a local MySQL server, the most reasonable thing is to download the command line client and in it:

  • create a new database ( CREATE DATABASE databasename; ) (the dump comments contain the name history_futures_binance , so it is reasonable to use it if there is no such database on the server)
  • make it current ( USE databasename )
  • give the command to deploy the dump SOURCE 'x:\path\filename.sql' .

Most likely, everything will be completed without errors, and as a result, the database will be restored. If there are problems during execution, some error message will be displayed - and depending on it, some corrective actions will need to be taken.

N
Nikolai Savelyev, 2022-04-11
@AgentSmith

What means

there is a sql file
?
Is it a dump or sql with table creation, inserts and constraints? Attach the sql file to make it clear

A
Alexander Nesterov, 2022-04-11
@AlexNest

Is it really that hard to google?
Literally the first link on request:

sql server python

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question