Typical approach is to put the IO heavy part like fetching data over the internet and data processing into the same function:
import random
import threading
import time
from concurrent.futures import ThreadPoolExecutor
Typical approach is to put the IO heavy part like fetching data over the internet and data processing into the same function:
import random
import threading
import time
from concurrent.futures import ThreadPoolExecutor
I am testing Postgres insertion performance. I have a table with one column with number as its data type. There is an index on it as well. I filled the database up using this query:
insert into aNumber (id) values (564),(43536),(34560) ...
I inserted 4 million rows very quickly 10,000 at a time with the query above. After the database reached 6 million rows performance drastically declined to 1 Million rows every 15 min. Is there any trick to increase insertion performance? I need optimal insertion performance on this project. Using Windows 7 Pro on a machine with 5 GB RAM.
https://stackoverflow.com/questions/4069595/flask-with-geoalchemy-sample-code
Using SQLAlchemy 0.8, Flask-SQLAlchemy and Geoalchemy 2:
from app import db
from geoalchemy2.types import Geometry
Add this in your ini file:
[alembic:exclude]
tables = spatial_ref_sys
In env.py
:
def exclude_tables_from_config(config_):
tables_ = config_.get("tables", None)
if tables_ is not None:
Before we can setup PostGIS we need to have a local version of Postgresql installed and running. The most effecient way to do this is to download and install Postgres.app.
Once Postgres.app is installed in your computers /Applications
directory. Open the Terminal and enter the following two commands
psql -d DATABASE_NAME -f /Applications/Postgres.app/Contents/Versions/9.3/share/postgresql/contrib/postgis-2.1/postgis.sql
from flask import Flask | |
from flask_sslify import SSLify | |
""" | |
Option 1 : (pip install pyopenssl) | |
from OpenSSL import SSL | |
context = SSL.Context(SSL.SSLv23_METHOD) | |
context.use_privatekey_file('web.key') | |
context.use_certificate_file('web.crt') |
NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.
If you are not into long explanations, see [Paolo Bergantino’s answer][2].
# http://bytefish.de/blog/first_steps_with_sqlalchemy/ | |
from sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy import create_engine | |
from datetime import datetime, timedelta | |
from sqlalchemy import Table, Column, Integer, String, DateTime, ForeignKey | |
from sqlalchemy.orm import relationship, backref | |
from sqlalchemy.orm import sessionmaker | |
Base = declarative_base() |