Jump to content

How Does SQL Work

So I need to make a script that can input data into an SQL database for work but I've encountered one main problem. I understand SQL commands and how to make tables and such, but I simply have no idea where to put these commands. Do I put them in the terminal? (I'm using OS X) Do I put them in an IDE? I don't understand how it works

Link to comment
Share on other sites

Link to post
Share on other sites

You need some kind of program like Access or SQL Express. SQL stands for Structured Query Language and is exactly what it means- query. I've done this a long ago but you should be able to make a new query somewhere and that's where you put your code. I believe you need data in the first place to make this work... Someone correct me if I'm wrong.

See my blog for amusing encounters from IT workplace: http://linustechtips.com/main/blog/585-life-of-a-techie/

Link to comment
Share on other sites

Link to post
Share on other sites

I don't have knowledge of this specific task, but if it's similar to other work I do, the script library or programming language would have something to connect to the SQL database. For example, Python (you should probably use Python, because it's a really good scripting language) has an SQL module such as https://pypi.python.org/pypi/python-sql that you can use to create a script to connect to the SQL database, do some commands, and process the data.

Link to comment
Share on other sites

Link to post
Share on other sites

would it not be easier to use a phpmyadmin and mysql install? I remember a free service that gives you onw you just have to click a link in an email every week to keep it going. I use it a lot just for testing.

 

 

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, Lunar Evolution said:

So I need to make a script that can input data into an SQL database for work but I've encountered one main problem. I understand SQL commands and how to make tables and such, but I simply have no idea where to put these commands. Do I put them in the terminal? (I'm using OS X) Do I put them in an IDE? I don't understand how it works

You need an application that accesses the database and offers you a means for running queries against it. Most databases have such an application that can be used with them; they can be provided as a web interface such as MySql and phpMyAdmin or a desktop application such as Microsoft SQL Server and Microsoft SQL Management Studio for instance. Most have command line tools as well which I suspect you'll be after... You've not been very specific really - what database are you trying to work with?

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites

For MySQL

 

If you want to manage the database you probably would go for PhpMyAdmin but PhpMyAdmin also need some sort of Web server to run it, if you dont want to setup a webserver you can always use MySQL Workbench.

 

When you are working in something like the Workbench or PhpMyAdmin, everytime you request data from a Table the program actually does

SELECT * FROM accounts

for you, so a GUI is not the best way because you dont really remember the commands if you dont use them.

but in every sql application like phpmyadmin and mysql workbench you have the choice to do it manually by typing the query's.

 

Mostly you use MySQL if you actually want to work with website's or even gameserver / mods / plugins.

Most game servers use MSSQL  and if you want to do something locally like registering birthdays of family members you will be better of using Access to start.

 

There are many Engine's i must call it i believe to run a Database. i actually switched to MariaDB today because Teamspeak is using MariaDB.

 

Or you can setup a simple website with a little text box connect it to your Database and you only have to input data.

http://www.w3schools.com/php/php_mysql_intro.asp

 

 

Quote or mention me if not feel ignored 

Link to comment
Share on other sites

Link to post
Share on other sites

I've been trying to use SQLite and DB browser along with it but I haven't found an effective way to do it. I am essentially parsing text files in python and I need to be able to insert the parsed text into a database from there. The ultimate goal is to be able to do this once and then repeat in order to compare the two databases against each other to see if the match. (It would be repeated daily.) So do I just need to download the python SQL module or is there an easier way to do it?

Link to comment
Share on other sites

Link to post
Share on other sites

31 minutes ago, Lunar Evolution said:

I've been trying to use SQLite and DB browser along with it but I haven't found an effective way to do it. I am essentially parsing text files in python and I need to be able to insert the parsed text into a database from there. The ultimate goal is to be able to do this once and then repeat in order to compare the two databases against each other to see if the match. (It would be repeated daily.) So do I just need to download the python SQL module or is there an easier way to do it?

Well if you are already parsing the data in a program why wouldn't you simply extend that to then connect to your database and continue your data processing? There's already Python support for SQLite... use it... I'm not really sure what you're trying to ask or what you're stuck on...

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, Nuluvius said:

Well if you are already parsing the data in a program why wouldn't you simply extend that to then connect to your database and continue your data processing? There's already Python support for SQLite... use it... I'm not really sure what you're trying to ask or what you're stuck on...

Basically I'm very new to databases in general and I don't really know how to do that. I don't know where to find any guides on it either. What I need to figure out is what kind of functions or commands python has to support SQLite and where to find them and how to implement them into something like this.

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, Lunar Evolution said:

Basically I'm very new to databases and general and I don't really know how to do that. I don't know where to find any guides on it either. What I need to figure out is what kind of functions or commands python has to support SQLite and where to find them and how to implement them into something like this.

Did you even bother to read the documentation that I linked? If you had then I don't see why you needed to ask that question...

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites

3 minutes ago, Nuluvius said:

Did you even bother to read the documentation that I linked? If you had then I don't see why you needed to ask that question...

I glanced, but I didn't see anything about python or SQLite

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, Lunar Evolution said:

I glanced, but I didn't see anything about python or SQLite

You didn't see anything about Python or about SQLite? Are you sure about that?

wklPrEg.png

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, Nuluvius said:

You didn't see anything about Python or about SQLite? Are you sure about that?

wklPrEg.png

I thought you meant in your first post, sorry

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, Lunar Evolution said:

I glanced, but I didn't see anything about python or SQLite

You should make sure you understand what a database is and how you interact with it, @Nuluvius already linked a great resource on the integration in python, but it seems you should also read up on databases and SQL (Structured Query Language) which is the way to interact with the database. There are some frameworks/libraries that abstract database queries into functions, django etc. but you're strongly encouraged knowing some SQL if you want to interact with databases.

Link to comment
Share on other sites

Link to post
Share on other sites

The w3schools website has quite a good SQL tutorial, with an online database that you can play with to practice.

 

http://www.w3schools.com/sql/default.asp

Intel i7 5820K (4.5 GHz) | MSI X99A MPower | 32 GB Kingston HyperX Fury 2666MHz | Asus RoG STRIX GTX 1080ti OC | Samsung 951 m.2 nVME 512GB | Crucial MX200 1000GB | Western Digital Caviar Black 2000GB | Noctua NH-D15 | Fractal Define R5 | Seasonic 860 Platinum | Logitech G910 | Sennheiser 599 | Blue Yeti | Logitech G502

 

Nikon D500 | Nikon 300mm f/4 PF  | Nikon 200-500 f/5.6 | Nikon 50mm f/1.8 | Tamron 70-210 f/4 VCII | Sigma 10-20 f/3.5 | Nikon 17-55 f/2.8 | Tamron 90mm F2.8 SP Di VC USD Macro | Neewer 750II

Link to comment
Share on other sites

Link to post
Share on other sites

6 hours ago, Lunar Evolution said:

I thought you meant in your first post, sorry

for simply running sql commands on a local sqlite3 database. install sqlite3 and use it from the command line.

 

for instance if you have a database in your current directory called my_database.db, run the command:

$sqlite3 my_database.db

 

and your prompt will change to sqlite>_

where _ represents the cursor.

 

from this prompt you can run sql commands.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×