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
Miki_P98
Miki_P98β€’4mo ago
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
bobbythehuman
bobbythehumanβ€’4mo ago
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
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
~ 𝒱𝒢𝓁𝒾𝓃𝑒
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.
Miki_P98
Miki_P98β€’4mo ago
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?
Miki_P98
Miki_P98β€’4mo ago
No, it connects to the DB
bobbythehuman
bobbythehumanβ€’4mo ago
Connect basically opens the database and cursor allows u to manipulate it
~ 𝒱𝒢𝓁𝒾𝓃𝑒
like using mouse? cursor
Miki_P98
Miki_P98β€’4mo ago
No, using code
~ 𝒱𝒢𝓁𝒾𝓃𝑒
I see... so, what to do with it next after it opened?
bobbythehuman
bobbythehumanβ€’4mo ago
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?
bobbythehuman
bobbythehumanβ€’4mo ago
mycursor.execute(β€˜sql query here’) myresult = mycursor.fetchall()
~ 𝒱𝒢𝓁𝒾𝓃𝑒
So, I put the sql code copied from W3S inside mycursor.execute( )?
bobbythehuman
bobbythehumanβ€’4mo ago
Yes and if u are collecting date from the table use the 2nd line
~ 𝒱𝒢𝓁𝒾𝓃𝑒
I see date from the table?
bobbythehuman
bobbythehumanβ€’4mo ago
Data/ rows
~ 𝒱𝒢𝓁𝒾𝓃𝑒
huh Row on the second line?
bobbythehuman
bobbythehumanβ€’4mo ago
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?
bobbythehuman
bobbythehumanβ€’4mo ago
Depending on what u put in the query It can return the whole table
Want results from more Discord servers?
Add your server