Beispiel #1
0
import pymongo, sys
import pandas as pd

try:
    con = pymongo.MongoClient('127.0.0.1', 27017)
    db = con.sample  # sample 이름의 db로 이동 없으면 생성

    # fruits 테이블 이 없으면 생성
    db.fruits.insert_one({'name': 'apple', 'count': 10, 'price': 1500})
    db.fruits.insert_one({'name': 'banana', 'count': 4, 'price': 500})
    db.fruits.insert_one({'name': 'orange', 'count': 13, 'price': 1000})
    db.fruits.insert_one({'name': 'kiwi', 'count': 22, 'price': 1300})
    db.fruits.insert_one({'name': 'melon', 'count': 16, 'price': 2500})
    db.fruits.insert_one({'name': 'mango', 'count': 4, 'price': 550})

except:
    print('애러 ', sys.int_info())
else:
    print('입력성공')
finally:
    con.close()
Beispiel #2
0
 base_exec_prefix = r'G:\Softwares\Python 3.7.0'
 base_prefix = r'G:\Softwares\Python 3.7.0'
 builtin_module_names = ('_abc', '_ast', '_bisect', '_blake2', '_codecs...
 byteorder = 'little'
 copyright = 'Copyright (c) 2001-2018 Python Software Foundati...ematis...
 dllhandle = 1819344896
 dont_write_bytecode = False
 exec_prefix = r'G:\Softwares\Python 3.7.0'
 executable = r'G:\Softwares\Python 3.7.0\pythonw.exe'
 flags = sys.flags(debug=0, inspect=0, interactive=0, opt...ation=1, is...
 float_info = sys.float_info(max=1.7976931348623157e+308, max_...epsilo...
 float_repr_style = 'short'
 hash_info = sys.hash_info(width=32, modulus=2147483647, inf=...iphash2...
 hexversion = 50790640
 implementation = namespace(cache_tag='cpython-37', hexversion=507...in...
 int_info = sys.int_info(bits_per_digit=15, sizeof_digit=2)
 last_value = AttributeError("module 'sys' has no attribute 'ps1'")
 maxsize = 2147483647
 maxunicode = 1114111
 meta_path = [<class '_frozen_importlib.BuiltinImporter'>, <class '_fro...
 modules = {'__main__': <module '__main__' (built-in)>, '_abc': <module...
 path = ['', r'G:\Softwares\Python 3.7.0\Lib\idlelib', r'G:\Softwares\P...
 path_hooks = [<class 'zipimport.zipimporter'>, <function FileFinder.pa...
 path_importer_cache = {r'G:\Softwares\Python 3.7.0': FileFinder('G:\\S...
 platform = 'win32'
 prefix = r'G:\Softwares\Python 3.7.0'
 stderr = <idlelib.run.PseudoOutputFile object>
 stdin = <idlelib.run.PseudoInputFile object>
 stdout = <idlelib.run.PseudoOutputFile object>
 thread_info = sys.thread_info(name='nt', lock=None, version=None)
 version = '3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.191...
Beispiel #3
0
# salgrade : grade, losal, hisal
# dataframe 저장 / 출력

import cx_Oracle, sys
import pandas as pd

list = []
try:
    con = cx_Oracle.connect('scott/[email protected]:1521/xe')
    csr = con.cursor()
    csr.execute('select * from salgrade')
    data = csr.fetchall()
    for i in data:
        list.append(i)
    csr.close()
except:
    print("애러 ", sys.int_info())
finally:
    con.close()

df = pd.DataFrame(list, columns=['grade', 'losal', 'hisal'])
print(df)