Tutorial of how to use SQL program and which SQL program to use
I've googled how to merge databases, but all the results are non applicable to DH data, so I need to know from people who have actually done this.
21 Replies
You connect to the DB using e.g. Python
Use a SELECT query to get all the records from 1 DB
And then insert every record to the second DB if the record does not exist yet
At least in theory
If u can program ur self you can use w3 schools to help
https://www.w3schools.com/sql/
Or u can download db drowser from the FaQ
https://discord.com/channels/881614130614767666/1035937460334624858/1249368065658060810
Can you give me an example?
I have db browser, but I when tried to copy paste it, it put everything in a single column.
And it'd take weeks to manually put all the data from one database to another.
import sqlite3
conn = sqlite3.connect('test.db')
print "Opened database successfully";
ββββββββββββ
import sqlite3
conn = sqlite3.connect('test.db')
print "Opened database successfully";
cursor = conn.execute("SELECT id, name, address, salary from COMPANY")
for row in cursor:
print "ID = ", row[0]
print "NAME = ", row[1]
print "ADDRESS = ", row[2]
print "SALARY = ", row[3], "\n"
print "Operation done successfully";
conn.close()
Does connect function merge the databases?
No, it connects to the DB
Connect basically opens the database and cursor allows u to manipulate it
like using mouse?
cursor
No, using code
I see... so, what to do with it next after it opened?
Use cursor to manipulate by adding, deleting or editing data or tables
How do I code the cursor though?
Is this the only way to do it?
mycursor.execute(βsql query hereβ)
myresult = mycursor.fetchall()
So, I put the sql code copied from W3S inside mycursor.execute( )?
Yes and if u are collecting date from the table use the 2nd line
I see
date from the table?
Data/ rows
huh
Row on the second line?
The results from the fetch all will return a list of all row which is a list of the data within that row
Like the entire table?
Depending on what u put in the query It can return the whole table