Git Product home page Git Product logo

0.41's Introduction

0.41

Accesing the database

In the data folder, there's a module named database, which will contain all the methods needed to get information from the data base. There will be methods to retrieve specific data using SQL.

To use it in a notebook or script in your personal folder, first you have to execute the following code:

import sys
sys.path.append('..')
import data.database as db

That piece of code will import the database module. At this moment, the only method is get_connection, which returns a connection to the remote database where all the data is.

The username, password, database, host and port needed to get the connection are written in the file config.ini. Here below there's the method to get that information, but everything is already coded in get_connection, so that's the only method you need to get the connection if you want to do your own queries.

from configparser import ConfigParser

config = ConfigParser()
config.read('../config.ini')  # <- that in case you're in your personal folder
db_info = config['DATABASE']
conn = db.get_connection(db_info) # This is the connection with the database

Obviously, in a normal project I should have not pushed that config file, with the password to access a database. But as this is just a practice project, and the data is not sensitive, we can leave it as it is and everybody can create the connection to the database

I will write methods to retrieve specific data from the database, and return it as pandas Dataframes. If you need a specific method just write it here in pseudocode. (in suggested methods)

Suggested methods.

0.41's People

Contributors

bass2015 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.