Skip to content

Commit

Permalink
init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jph00 committed May 27, 2024
1 parent ab38106 commit 89b6fe4
Show file tree
Hide file tree
Showing 15 changed files with 1,372 additions and 64 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Deploy to GitHub Pages

permissions:
contents: write
pages: write

on:
push:
branches: [ "main", "master" ]
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps: [uses: fastai/workflows/quarto-ghp@master]
7 changes: 7 additions & 0 deletions .github/workflows/test.yaml.off
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: CI
on: [workflow_dispatch, pull_request, push]

jobs:
test:
runs-on: ubuntu-latest
steps: [uses: fastai/workflows/nbdev-ci@master]
111 changes: 49 additions & 62 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
_proc/
_quarto.yml
sidebar.yml
Gemfile.lock
token
_docs/
conda/
.last_checked
.gitconfig
*.bak
*.log
*~
~*
_tmp*
tmp*
tags

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand All @@ -8,6 +25,7 @@ __pycache__/

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
Expand All @@ -20,11 +38,9 @@ parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
Expand All @@ -39,17 +55,13 @@ pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
Expand All @@ -58,8 +70,6 @@ cover/
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
Expand All @@ -72,61 +82,27 @@ instance/
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
.python-version

# celery beat schedule file
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
# dotenv
.env

# virtualenv
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
Expand All @@ -140,21 +116,32 @@ venv.bak/

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
.vscode
*.swp

# osx generated files
.DS_Store
.DS_Store?
.Trashes
ehthumbs.db
Thumbs.db
.idea

# pytest
.pytest_cache

# tools/trust-doc-nbs
docs_src/.last_checked

# symlinks to fastai
docs_src/fastai
tools/fastai

# pytype static type analyzer
.pytype/
# link checker
checklink/cookies.txt

# Cython debug symbols
cython_debug/
# .gitconfig is now autogenerated
.gitconfig

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
_docs
5 changes: 5 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include settings.ini
include LICENSE
include CONTRIBUTING.md
include README.md
recursive-exclude * __pycache__
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
# fastsqlite
A bit of extra usability for sqlite
# fastlite


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

This file will become your README and also the index of your
documentation.

## Install

``` sh
pip install fastlite
```

## How to use

Fill me in please! Don’t forget code examples:

``` python
1+1
```

2
1 change: 1 addition & 0 deletions fastlite/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.0.1"
28 changes: 28 additions & 0 deletions fastlite/_modidx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Autogenerated by nbdev

d = { 'settings': { 'branch': 'main',
'doc_baseurl': '/fastlite',
'doc_host': 'https://AnswerDotAI.github.io',
'git_url': 'https://github.com/AnswerDotAI/fastlite',
'lib_path': 'fastlite'},
'syms': { 'fastlite.core': { 'fastlite.core.Database.t': ('core.html#database.t', 'fastlite/core.py'),
'fastlite.core.Table.__str__': ('core.html#table.__str__', 'fastlite/core.py'),
'fastlite.core.Table.c': ('core.html#table.c', 'fastlite/core.py'),
'fastlite.core.View.__str__': ('core.html#view.__str__', 'fastlite/core.py'),
'fastlite.core.View.c': ('core.html#view.c', 'fastlite/core.py'),
'fastlite.core._Col': ('core.html#_col', 'fastlite/core.py'),
'fastlite.core._Col.__init__': ('core.html#_col.__init__', 'fastlite/core.py'),
'fastlite.core._Col.__repr__': ('core.html#_col.__repr__', 'fastlite/core.py'),
'fastlite.core._Col.__str__': ('core.html#_col.__str__', 'fastlite/core.py'),
'fastlite.core._ColsGetter': ('core.html#_colsgetter', 'fastlite/core.py'),
'fastlite.core._ColsGetter.__call__': ('core.html#_colsgetter.__call__', 'fastlite/core.py'),
'fastlite.core._ColsGetter.__dir__': ('core.html#_colsgetter.__dir__', 'fastlite/core.py'),
'fastlite.core._ColsGetter.__getattr__': ('core.html#_colsgetter.__getattr__', 'fastlite/core.py'),
'fastlite.core._ColsGetter.__init__': ('core.html#_colsgetter.__init__', 'fastlite/core.py'),
'fastlite.core._ColsGetter.__repr__': ('core.html#_colsgetter.__repr__', 'fastlite/core.py'),
'fastlite.core._Getter': ('core.html#_getter', 'fastlite/core.py'),
'fastlite.core._Getter.__getattr__': ('core.html#_getter.__getattr__', 'fastlite/core.py'),
'fastlite.core._Getter.__init__': ('core.html#_getter.__init__', 'fastlite/core.py'),
'fastlite.core._Getter.__repr__': ('core.html#_getter.__repr__', 'fastlite/core.py'),
'fastlite.core._TablesGetter': ('core.html#_tablesgetter', 'fastlite/core.py'),
'fastlite.core._TablesGetter.__dir__': ('core.html#_tablesgetter.__dir__', 'fastlite/core.py')}}}
57 changes: 57 additions & 0 deletions fastlite/core.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/00_core.ipynb.

# %% auto 0
__all__ = []

# %% ../nbs/00_core.ipynb 3
from fastcore.utils import *
from fastcore.xml import highlight
from fastcore.xtras import hl_md

from sqlite_utils import Database
from sqlite_utils.db import Table, View

# %% ../nbs/00_core.ipynb 6
class _Getter:
"Abstract class with dynamic attributes providing access to DB objects"
def __init__(self, db): self.db = db
# NB: Define `__dir__` in subclass to get list of objects
def __repr__(self): return ", ".join(dir(self))
def __getattr__(self, k):
if k[0]=='_': raise AttributeError
return self.db[k]

class _TablesGetter(_Getter):
def __dir__(self): return self.db.table_names()

@patch(as_prop=True)
def t(self:Database): return _TablesGetter(self)

# %% ../nbs/00_core.ipynb 9
class _Col:
def __init__(self, t, c): self.t,self.c = t,c
def __str__(self): return f'"{self.t}"."{self.c}"'
def __repr__(self): return f'{self.c}'

class _ColsGetter:
def __init__(self, tbl): self.tbl = tbl
def __dir__(self): return map(repr, self())
def __call__(self): return [_Col(self.tbl.name,o.name) for o in self.tbl.columns]
def __repr__(self): return ", ".join(dir(self))

def __getattr__(self, k):
if k[0]=='_': raise AttributeError
return _Col(self.tbl.name, k)

@patch(as_prop=True)
def c(self:Table): return _ColsGetter(self)

@patch(as_prop=True)
def c(self:View): return _ColsGetter(self)

# %% ../nbs/00_core.ipynb 14
@patch
def __str__(self:Table): return f'"{self.name}"'

@patch
def __str__(self:View): return f'"{self.name}"'
Loading

0 comments on commit 89b6fe4

Please sign in to comment.