Skip to content

Instantly share code, notes, and snippets.

Avatar
👋
Hello!

Mayara Rysia mayararysia

👋
Hello!
View GitHub Profile
@mayararysia
mayararysia / manipulating-data.py
Last active Sep 8, 2020
Manipulating Data Using Connector / Python
View manipulating-data.py
from datetime import date
import mysql.connector
db_connection = mysql.connector.connect(host="localhost", user="root", passwd="", database="bd")
cursor = db_connection.cursor()
sql = "INSERT INTO user (name, cpf) VALUES (%s, %s)"
values = ("Maria", "025.658.698-55")
cursor.execute(sql, values)
current_date = date.today()
formatted_date = current_date.strftime('%d/%m/%Y')
View exampleCheckObjectType.java
if(pointA instanceof Coordinate)
System.out.println("type Coordinate");
@mayararysia
mayararysia / Employee.java
Created Aug 21, 2020
Example of indication of inheritance
View Employee.java
public class Employee extends Person {
//...
}
@mayararysia
mayararysia / ExampleMainCoordinate.java
Last active Aug 21, 2020
An example of a class Main
View ExampleMainCoordinate.java
class Main {
public static void main(String[] args) {
Coordinate pointA = new Coordinate(5.0, 6.0); // (5,6) pointA object is of type Coordinate
Coordinate origin = new Coordinate(0.0, 0.0); // (0,0) origin object is of type Coordinate
System.out.println("abscissa - point A> x: " + pointA.getX() ); // abscissa - point A: 5
System.out.println("abscissa - origin> x: " + origin.getX() ); // abscissa - origin: 0
System.out.println("-- Distance: "+ pointA.distance(origin) ); //result: 7.81
}
}
@mayararysia
mayararysia / ExampleMainPerson.java
Created Aug 21, 2020
An example of a class Main - Person
View ExampleMainPerson.java
class Main {
public static void main(String[] args) {
// person1 object is of type Person
Person person1 = new Person();
person1.setName("Teddy");
person1.walk(); // person1 walks
// person2 object is of type Person
Person person2 = new Person();
@mayararysia
mayararysia / Coordinate.java
Created Aug 21, 2020
An example of a class Coordinate
View Coordinate.java
import java.lang.Math;
public class Coordinate {
// attributes
private Double x;
private Double y;
// constructor
// defined how to create an instance of this class
public Coordinate(Double x, Double y) {
this.x = x;
@mayararysia
mayararysia / Person.java
Last active Aug 20, 2020
An example of a class Person
View Person.java
public class Person {
//attributes
private String name;
private Date dateBirth;
//methods
public void walk(){ ... }
public void talk(){ ... }
@mayararysia
mayararysia / connect.py
Last active Sep 4, 2019
File that connects to the MySQL database
View connect.py
import mysql.connector
from mysql.connector import errorcode
try:
db_connection = mysql.connector.connect(host='localhost', user='root', password='', database='bd')
print("Database connection made!")
except mysql.connector.Error as error:
if error.errno == errorcode.ER_BAD_DB_ERROR:
print("Database doesn't exist")
elif error.errno == errorcode.ER_ACCESS_DENIED_ERROR:
print("User name or password is wrong")
@mayararysia
mayararysia / connect02.py
Created Sep 4, 2019
File that connects to the MySQL database
View connect02.py
from mysql.connector import (connection)
db_connection = connection.MySQLConnection(host='127.0.0.1', user='root', password='', database='bd')
db_connection.close()
@mayararysia
mayararysia / query.sql
Last active Sep 4, 2019
Example query for mysql connection exercise
View query.sql
create database bd;
use bd;
CREATE TABLE `user` (
`id` SERIAL PRIMARY KEY,
`name` VARCHAR(30) NOT NULL,
`cpf` VARCHAR(20) NOT NULL
);
INSERT INTO `user` (`name`, `cpf`) VALUES ('Leta Lestrange', '012.236.987-44'), ('Newt Scamander', '021.545.258-55'),
('Hermione Granger', '024.547.658-77');