Skip to content
Snippets Groups Projects
Verified Commit f35c1bd5 authored by David Beniamine's avatar David Beniamine
Browse files

Netbooks updated

parent b305a8eb
No related branches found
No related tags found
No related merge requests found
...@@ -715,7 +715,7 @@ ...@@ -715,7 +715,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.7.4" "version": "3.8.6"
}, },
"widgets": { "widgets": {
"application/vnd.jupyter.widget-state+json": { "application/vnd.jupyter.widget-state+json": {
......
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
import pymonetdb import pymonetdb
# set up a connection. arguments below are the defaults # set up a connection. arguments below are the defaults
connection = pymonetdb.connect(username="monetdb", password="monetdb", connection = pymonetdb.connect(username="monetdb", password="monetdb",
hostname="localDB", database="db") hostname="localDB", database="db")
# create a cursor # create a cursor
cursor = connection.cursor() cursor = connection.cursor()
# increase the rows fetched to increase performance (optional) # increase the rows fetched to increase performance (optional)
cursor.arraysize = 100 cursor.arraysize = 100
# execute a query (return the number of rows to fetch) # execute a query (return the number of rows to fetch)
res=cursor.execute('SELECT * FROM tables') res=cursor.execute('SELECT * FROM tables')
if (res > 0): if (res > 0):
print('Successfully connected to localDB with default credentials, please change the monetdb password by running docker-compose exec localDB -d monetdb-r /root/set-monetdb-password.sh <password>') print('Successfully connected to localDB with default credentials, please change the monetdb password by running docker-compose exec localDB -d monetdb-r /root/set-monetdb-password.sh <password>')
``` ```
%% Output %% Output
--------------------------------------------------------------------------- Successfully connected to localDB with default credentials, please change the monetdb password by running docker-compose exec localDB -d monetdb-r /root/set-monetdb-password.sh <password>
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-72adc0183b67> in <module>
----> 1 import pymonetdb
2
3 # set up a connection. arguments below are the defaults
4 connection = pymonetdb.connect(username="monetdb", password="monetdb",
5 hostname="localDB", database="monetdb")
ModuleNotFoundError: No module named 'pymonetdb'
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
``` ```
......
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
import csv import csv
lines = [] lines = []
with open('test.csv') as csv_file: with open('test.csv') as csv_file:
dialect = csv.Sniffer().sniff(csv_file.read(1024)) dialect = csv.Sniffer().sniff(csv_file.read(1024))
csv_file.seek(0) csv_file.seek(0)
reader = csv.reader(csv_file, dialect) reader = csv.reader(csv_file, dialect)
for row in reader: for row in reader:
lines.append(row) lines.append(row)
print(lines) print(lines)
``` ```
%% Output %% Output
[['nom', 'prenom', 'surnom'], ['toto', 'd', 'toto'], ['titi', 'a', 'tutu']] [['nom', 'prenom', 'surnom'], ['toto', 'd', 'toto'], ['titi', 'a', 'tutu'], ['tata', 'plop', 'a']]
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
print('hello dude')
``` ```
%% Output
hello dude
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
``` ```
......
...@@ -10,5 +10,9 @@ def get_sample(): ...@@ -10,5 +10,9 @@ def get_sample():
return "Col1,Col2,Col3\naaa,bbb,ccc" return "Col1,Col2,Col3\naaa,bbb,ccc"
def get_last_import_info():
return "No info on last import"
def upload_data(path): def upload_data(path):
print(path) print(path)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment